Skip to content

Commit

Permalink
currency default to coin
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-andrievsky-dxc committed Nov 7, 2024
1 parent 8f582f7 commit 25c15a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion TCalcCore/Domain/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public string Id {
}
set { _id = value; }
}
public string Name { get; set; } = "EUR";
public string Name { get; set; } = "coin";
public int CurrencyRate { get; set; } = 100;
public static Currency Default => new Currency();

Expand Down
16 changes: 9 additions & 7 deletions TCalcCore/Domain/Tour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@ public class Tour : AbstractItem

public string StateGUID { get; set; } = "";
public IEnumerable<Currency> Currencies { get; set; } = new Currency[] { Currency.Default };
private string _currId = Currency.Default.Id;
public string TourCurrencyId { get; set; } = Currency.Default.Id;
public Currency Currency {
get {
if (!Currencies.Any())
throw new Exception("Currencies list is empty");
if (!Currencies.Any(c => c.Id == _currId))
{
_currId = Currencies.First().Id;
Currencies = new Currency[] { Currency.Default };
}
return Currencies.Where(c => c.Id == _currId).First().Clone();
if (!Currencies.Any(c => c.Id == TourCurrencyId))
{
TourCurrencyId = Currencies.First().Id;
}
return Currencies.Where(c => c.Id == TourCurrencyId).First().Clone();
}
set
{
if (_currId != value.Id)
if (TourCurrencyId != value.Id)
{
_currId = value.Id;
TourCurrencyId = value.Id;
Spendings = Spendings.Where(s => !s.Planned).ToList();
}
}
Expand Down

0 comments on commit 25c15a0

Please sign in to comment.