Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions FinTrack/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using CommunityToolkit.Mvvm.Messaging;
using FinTrackForWindows.Core;
using FinTrackForWindows.Services;
using FinTrackForWindows.Services.Accounts;
using FinTrackForWindows.Services.Api;
using FinTrackForWindows.Services.Budgets;
using FinTrackForWindows.Services.Currencies;
using FinTrackForWindows.Services.Debts;
using FinTrackForWindows.Services.Memberships;
using FinTrackForWindows.Services.Transactions;
using FinTrackForWindows.ViewModels;
using FinTrackForWindows.Views;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -74,6 +80,13 @@ private void ConfigureServices(IServiceCollection services)
services.AddSingleton<IAuthService, AuthService>();
services.AddSingleton<ISecureTokenStorage, SecureTokenStorage>();
services.AddSingleton<IApiService, ApiService>();

services.AddSingleton<IBudgetStore, BudgetStore>();
services.AddSingleton<IAccountStore, AccountStore>();
services.AddSingleton<ITransactionStore, TransactionStore>();
services.AddSingleton<ICurrenciesStore, CurrenciesStore>();
services.AddSingleton<IMembershipStore, MembershipStore>();
services.AddSingleton<IDebtStore, DebtStore>();
}

protected override async void OnStartup(StartupEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions FinTrack/Data/AppDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public AppDatabaseContext() { }
public DbSet<UserModel> Users { get; set; }
public DbSet<UserSettingsModel> UserSettings { get; set; }
public DbSet<AccountModel> Accounts { get; set; }
public DbSet<TransactionModel> Transactions { get; set; }
public DbSet<TransactionModel_> Transactions { get; set; }
public DbSet<CategoryModel> Categories { get; set; }
public DbSet<BudgetModel> Budgets { get; set; }
public DbSet<BudgetCategoryModel> BudgetCategories { get; set; }
Expand Down Expand Up @@ -85,7 +85,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.HasIndex(a => new { a.UserId, a.Name }).IsUnique();
});

modelBuilder.Entity<TransactionModel>(entity =>
modelBuilder.Entity<TransactionModel_>(entity =>
{
entity.ToTable("Transactions");
entity.HasKey(t => t.Id);
Expand Down
12 changes: 12 additions & 0 deletions FinTrack/Dtos/CurrencyDtos/ConvertResponseDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace FinTrackForWindows.Dtos.CurrencyDtos
{
public class ConvertResponseDto
{
public string From { get; set; } = string.Empty;
public string To { get; set; } = string.Empty;
public decimal Amount { get; set; }
public decimal Result { get; set; }
public decimal Rate { get; set; }
public DateTime Timestamp { get; set; }
}
}
7 changes: 7 additions & 0 deletions FinTrack/Dtos/MembershipDtos/CheckoutResponseDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace FinTrackForWindows.Dtos.MembershipDtos
{
public class CheckoutResponseDto
{
public string CheckoutUrl { get; set; } = string.Empty;
}
}
51 changes: 51 additions & 0 deletions FinTrack/Dtos/MembershipDtos/PlanFeatureDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using FinTrackForWindows.Enums;

namespace FinTrackForWindows.Dtos.MembershipDtos
{
public class PlanFeatureDto
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public decimal Price { get; set; }
public BaseCurrencyType? Currency { get; set; }
public BillingCycleType? BillingCycle { get; set; }
public int? DurationInDays { get; set; }
public ReportingFeatures? Reporting { get; set; }
public EmailingFeatures? Emailing { get; set; }
public BudgetingFeatures? Budgeting { get; set; }
public AccountFeatures? Accounts { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool PrioritySupport { get; set; } = false;
}

public class ReportingFeatures
{
public string Level { get; set; } = "Basic";
public bool CanExportPdf { get; set; } = false;
public bool CanExportWord { get; set; } = false;
public bool CanExportMarkdown { get; set; } = false;
public bool CanExportXml { get; set; } = false;
public bool CanExportText { get; set; } = false;
public bool CanExportXlsx { get; set; } = false;
}

public class EmailingFeatures
{
public bool CanEmailReports { get; set; } = false;
public int MaxEmailsPerMonth { get; set; } = 0;
}

public class BudgetingFeatures
{
public bool CanCreateBudgets { get; set; } = false;
public int MaxBudgets { get; set; } = 0;
}

public class AccountFeatures
{
public int MaxBankAccounts { get; set; } = 0;
}
}
8 changes: 8 additions & 0 deletions FinTrack/Dtos/MembershipDtos/SubscriptionRequestDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace FinTrackForWindows.Dtos.MembershipDtos
{
public class SubscriptionRequestDto
{
public int PlanId { get; set; }
public bool AutoRenew { get; set; }
}
}
13 changes: 13 additions & 0 deletions FinTrack/Dtos/MembershipDtos/UserMembershipDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace FinTrackForWindows.Dtos.MembershipDtos
{
public class UserMembershipDto
{
public int Id { get; set; }
public int PlanId { get; set; }
public string PlanName { get; set; } = string.Empty;
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string Status { get; set; } = string.Empty;
public bool AutoRenew { get; set; }
}
}
10 changes: 10 additions & 0 deletions FinTrack/Dtos/TransactionDtos/TransactionCategoryCreateDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using FinTrackForWindows.Enums;

namespace FinTrackForWindows.Dtos.TransactionDtos
{
public class TransactionCategoryCreateDto
{
public string Name { get; set; } = null!;
public TransactionType Type { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using FinTrackForWindows.Enums;
using System.Text.Json.Serialization;

namespace FinTrackForWindows.Dtos.TransactionDtos
{
public class TransactionCategoriesDto
public class TransactionCategoryDto
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public int UserId { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public TransactionType Type { get; set; }

public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
Expand Down
10 changes: 10 additions & 0 deletions FinTrack/Dtos/TransactionDtos/TransactionCategoryUpdateDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using FinTrackForWindows.Enums;

namespace FinTrackForWindows.Dtos.TransactionDtos
{
public class TransactionCategoryUpdateDto
{
public string Name { get; set; } = null!;
public TransactionType Type { get; set; }
}
}
2 changes: 1 addition & 1 deletion FinTrack/Dtos/TransactionDtos/TransactionDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace FinTrackForWindows.Dtos.TransactionDtos
public class TransactionDto
{
public int Id { get; set; }
public TransactionCategoriesDto Category { get; set; } = null!;
public TransactionCategoryDto Category { get; set; } = null!;
public AccountDto Account { get; set; } = null!;
public decimal Amount { get; set; }
public BaseCurrencyType Currency { get; set; }
Expand Down
14 changes: 14 additions & 0 deletions FinTrack/Enums/BillingCycleType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace FinTrackForWindows.Enums
{
public enum BillingCycleType
{
None,
Monthly,
Quarterly,
SemiAnnually,
Annually,
Biennially,
Triennially,
Custom
}
}
21 changes: 21 additions & 0 deletions FinTrack/Helpers/EqualityToBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Globalization;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
{
public class EqualityToBooleanConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null || values.Length < 2 || values[0] == null || values[1] == null)
return false;

return values[0].Equals(values[1]);
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
23 changes: 23 additions & 0 deletions FinTrack/Helpers/InequalityToBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Globalization;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
{
public class InequalityToBooleanConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null || values.Length < 2 || values[0] == null || values[1] == null)
{
return true;
}

return !values[0].Equals(values[1]);
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
19 changes: 19 additions & 0 deletions FinTrack/Helpers/NullToVisibilityInverseConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FinTrackForWindows.Helpers
{
public class NullToVisibilityInverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
3 changes: 2 additions & 1 deletion FinTrack/Models/Account/AccountModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public partial class AccountModel : ObservableObject
[ObservableProperty]
private List<AccountBalanceHistoryPoint> history = new();

public decimal? balance { get; set; }
[ObservableProperty]
private decimal? balance;

public string IconPath => Type switch
{
Expand Down
2 changes: 1 addition & 1 deletion FinTrack/Models/AccountModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public class AccountModel
[Column("IsSynced")]
public bool IsSynced { get; set; } = false;

public virtual ICollection<TransactionModel> Transactions { get; set; } = new List<TransactionModel>();
public virtual ICollection<TransactionModel_> Transactions { get; set; } = new List<TransactionModel_>();
}
}
4 changes: 1 addition & 3 deletions FinTrack/Models/Budget/BudgetModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// FinTrackForWindows.Models.Budget/BudgetModel.cs

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using FinTrackForWindows.Enums;
using System.Globalization;

Expand Down
2 changes: 1 addition & 1 deletion FinTrack/Models/CategoryModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CategoryModel
public bool IsSynced { get; set; } = false;

public virtual ICollection<BudgetCategoryModel> BudgetAllocations { get; set; } = new List<BudgetCategoryModel>();
public virtual ICollection<TransactionModel> Transactions { get; set; } = new List<TransactionModel>();
public virtual ICollection<TransactionModel_> Transactions { get; set; } = new List<TransactionModel_>();
}

public enum CategoryType
Expand Down
6 changes: 6 additions & 0 deletions FinTrack/Models/Membership/MembershipModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace FinTrackForWindows.Models.Membership
{
public class MembershipModel
{
}
}
56 changes: 56 additions & 0 deletions FinTrack/Models/Transaction/AddCategoryViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FinTrackForWindows.Dtos.TransactionDtos;
using FinTrackForWindows.Enums;
using FinTrackForWindows.Services.Api;
using System.Windows;

namespace FinTrackForWindows.Models.Transaction
{
public partial class AddCategoryViewModel : ObservableObject
{
private readonly IApiService _apiService;

public Action? CloseWindow { get; set; }
public TransactionCategoryModel? CreatedCategory { get; private set; }

[ObservableProperty]
private string name = string.Empty;

[ObservableProperty]
private TransactionType type = TransactionType.Expense;

public AddCategoryViewModel(IApiService apiService)
{
_apiService = apiService;
}

[RelayCommand]
private async Task Save()
{
if (string.IsNullOrWhiteSpace(Name))
{
MessageBox.Show("Kategori adı boş olamaz.", "Hata", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

var createDto = new TransactionCategoryDto
{
Name = this.Name,
Type = this.Type
};

var result = await _apiService.PostAsync<TransactionCategoryDto>("TransactionCategory", createDto);

if (result != null)
{
CreatedCategory = new TransactionCategoryModel { Id = result.Id, Name = result.Name, Type = result.Type };
CloseWindow?.Invoke();
}
else
{
MessageBox.Show("Kategori oluşturulurken bir hata oluştu.", "API Hatası", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
17 changes: 17 additions & 0 deletions FinTrack/Models/Transaction/TransactionCategoryModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using CommunityToolkit.Mvvm.ComponentModel;
using FinTrackForWindows.Enums;

namespace FinTrackForWindows.Models.Transaction
{
public partial class TransactionCategoryModel : ObservableObject
{
[ObservableProperty]
private int id;

[ObservableProperty]
private string name = string.Empty;

[ObservableProperty]
private TransactionType type;
}
}
Loading
Loading