Skip to content

Commit 443738e

Browse files
committed
refactor(*.xaml, *.cs): Refactor account model and view to use Balance property
Replaces CurrentBalance and TargetBalance with a single Balance property in AccountModel and updates related view models and views accordingly. Removes progress bar and target balance UI elements, simplifies balance display logic, and introduces AccountResponseDto for API responses. Also improves logging for currency parsing and centers header text in ApplicationRecognizeSlideView.
1 parent c10b7d4 commit 443738e

File tree

5 files changed

+34
-42
lines changed

5 files changed

+34
-42
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace FinTrackForWindows.Dtos.AccountDtos
2+
{
3+
public class AccountResponseDto
4+
{
5+
public int Id { get; set; }
6+
public int UserId { get; set; }
7+
public string Name { get; set; }
8+
public string Type { get; set; }
9+
public bool IsActive { get; set; }
10+
public decimal Balance { get; set; }
11+
public string Currency { get; set; }
12+
public DateTime CreatedAtUtc { get; set; }
13+
}
14+
}

FinTrack/Models/Account/AccountModel.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ public partial class AccountModel : ObservableObject
1616
private AccountType type;
1717

1818
[ObservableProperty]
19-
private decimal currentBalance;
20-
21-
[ObservableProperty]
22-
private decimal? targetBalance;
19+
private decimal balance;
2320

2421
[ObservableProperty]
2522
private string currency = "USD";
@@ -47,27 +44,14 @@ public string BalanceText
4744
{
4845
get
4946
{
50-
if (Type == AccountType.CreditCard && TargetBalance.HasValue)
51-
{
52-
return $"Kullanılan Limit: {CurrentBalance:C} / {TargetBalance.Value:C}";
53-
}
54-
if (TargetBalance.HasValue && TargetBalance > 0)
55-
{
56-
return $"{CurrentBalance:C} / {TargetBalance.Value:C}";
57-
}
58-
return $"Değer: {CurrentBalance:C}";
59-
}
60-
}
61-
public double ProgressValue
62-
{
63-
get
64-
{
65-
if (TargetBalance.HasValue && TargetBalance.Value > 0)
47+
var balance = Balance.ToString("C", System.Globalization.CultureInfo.CurrentCulture);
48+
return Type switch
6649
{
67-
return (double)Math.Max(0, Math.Min(100, (CurrentBalance / TargetBalance.Value) * 100));
68-
}
69-
70-
return Type == AccountType.Loan ? 100 : 0;
50+
AccountType.Checking => $"Bakiye: {balance}",
51+
AccountType.CreditCard => $"Borç: {balance}",
52+
AccountType.Loan => $"Kredi: {balance}",
53+
_ => $"Bakiye: {balance}"
54+
};
7155
}
7256
}
7357
}

FinTrack/ViewModels/AccountViewModel.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ private async Task LoadData()
5959
Id = item.Id,
6060
Name = item.Name,
6161
Type = item.Type,
62-
CurrentBalance = item.Balance,
63-
TargetBalance = 100,
62+
Balance = item.Balance,
6463
Currency = item.Currency.ToString(),
6564
});
6665
}
@@ -74,11 +73,12 @@ private async Task SaveAccount()
7473

7574
if (Enum.TryParse(SelectedAccount.Currency, out BaseCurrencyType currency))
7675
{
77-
_logger.LogInformation("");
76+
_logger.LogInformation("Seçilen para birimi: {Currency}", currency);
7877
}
7978
else
8079
{
81-
_logger.LogError("");
80+
_logger.LogWarning("Geçersiz para birimi: {Currency}", SelectedAccount.Currency);
81+
return;
8282
}
8383

8484
if (IsEditing)
@@ -88,31 +88,30 @@ private async Task SaveAccount()
8888
{
8989
existingAccount.Name = SelectedAccount.Name;
9090
existingAccount.Type = SelectedAccount.Type;
91-
existingAccount.CurrentBalance = SelectedAccount.CurrentBalance;
92-
existingAccount.TargetBalance = SelectedAccount.TargetBalance;
91+
existingAccount.Balance = SelectedAccount.Balance;
9392
existingAccount.Currency = SelectedAccount.Currency;
9493

9594
await _apiService.PutAsync<object>($"Account/{SelectedAccount.Id}", new AccountUpdateDto
9695
{
9796
Name = SelectedAccount.Name,
9897
Type = SelectedAccount.Type,
99-
Balance = SelectedAccount.CurrentBalance,
98+
Balance = SelectedAccount.Balance,
10099
Currency = currency
101100
});
102101
}
103102
}
104103
else
105104
{
106-
var newAccount = await _apiService.PostAsync<AccountCreateDto>("Account", new AccountCreateDto
105+
var newAccount = await _apiService.PostAsync<AccountResponseDto>("Account", new AccountCreateDto
107106
{
108107
Name = SelectedAccount.Name,
109108
Type = SelectedAccount.Type,
110109
IsActive = true,
111-
Balance = SelectedAccount.CurrentBalance,
110+
Balance = SelectedAccount.Balance,
112111
Currency = currency,
113112
});
114113

115-
SelectedAccount.Id = 10; // TODO: Burası kesinlikle incele.
114+
SelectedAccount.Id = newAccount.Id;
116115

117116
Accounts.Add(SelectedAccount);
118117
}

FinTrack/Views/AccountView.xaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
</Border>
4242
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="15,0">
4343
<TextBlock Text="{Binding Name}" Foreground="White" FontSize="16" FontWeight="SemiBold"/>
44-
<ProgressBar Value="{Binding ProgressValue, Mode=OneWay}" Height="8" Margin="0,8,0,8"
45-
Background="{StaticResource ProgressBarBackgroundBrush}"
46-
Foreground="{Binding IconBackground}"/>
4744
<TextBlock Text="{Binding BalanceText}" Foreground="{StaticResource TopBarTextSecondaryBrush}" FontSize="12"/>
4845
</StackPanel>
4946
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
@@ -92,10 +89,7 @@
9289
<TextBox Style="{StaticResource ModernTextBoxStyle}" Text="{Binding SelectedAccount.Type, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,15"/>
9390

9491
<TextBlock Text="BALANCE / LIMIT" Style="{StaticResource LabelTextStyle}"/>
95-
<TextBox Style="{StaticResource ModernTextBoxStyle}" Text="{Binding SelectedAccount.CurrentBalance, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,15"/>
96-
97-
<TextBlock Text="TARGET (Optional)" Style="{StaticResource LabelTextStyle}"/>
98-
<TextBox Style="{StaticResource ModernTextBoxStyle}" Text="{Binding SelectedAccount.TargetBalance, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,15"/>
92+
<TextBox Style="{StaticResource ModernTextBoxStyle}" Text="{Binding SelectedAccount.Balance, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,15"/>
9993

10094
<TextBlock Text="CURRENCY" Style="{StaticResource LabelTextStyle}"/>
10195
<TextBox Style="{StaticResource ModernTextBoxStyle}" Text="{Binding SelectedAccount.Currency, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,25"/>

FinTrack/Views/ApplicationRecognizeSlideView.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
Style="{StaticResource HeaderTextStyle}"
4343
HorizontalAlignment="Center"
4444
Margin="0,0,0,10"
45-
TextWrapping="Wrap"/>
45+
TextWrapping="Wrap"
46+
TextAlignment="Center"/>
4647

4748
<TextBlock Grid.Row="2"
4849
Text="{Binding CurrentDescription_ApplicationRecognizeSlideView_TextBlock}"

0 commit comments

Comments
 (0)