From 25c15a0662113e6b2ff8a0eeecca52464d9abed2 Mon Sep 17 00:00:00 2001 From: Dmitry Andrievskiy Date: Thu, 7 Nov 2024 10:20:23 +0100 Subject: [PATCH] currency default to coin --- TCalcCore/Domain/Currency.cs | 2 +- TCalcCore/Domain/Tour.cs | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/TCalcCore/Domain/Currency.cs b/TCalcCore/Domain/Currency.cs index 6944963..03c9c62 100644 --- a/TCalcCore/Domain/Currency.cs +++ b/TCalcCore/Domain/Currency.cs @@ -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(); diff --git a/TCalcCore/Domain/Tour.cs b/TCalcCore/Domain/Tour.cs index a843eef..b6b0052 100644 --- a/TCalcCore/Domain/Tour.cs +++ b/TCalcCore/Domain/Tour.cs @@ -25,22 +25,24 @@ public class Tour : AbstractItem public string StateGUID { get; set; } = ""; public IEnumerable 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(); } }