This commit is contained in:
2023-07-31 08:50:05 +03:00
parent cca943f37d
commit c5d9ae7b93
49 changed files with 546 additions and 398 deletions
@@ -0,0 +1,9 @@
namespace MyOffice.Web.Models.Currency;
public class CurrencyRateViewModel: BaseViewModel
{
public string Currency { get; set; }
public DateTime DateTime { get; set; }
public int Quantity { get; set; }
public decimal Rate { get; set; }
}
@@ -1,38 +1,14 @@
namespace MyOffice.Web.Models.Currency
namespace MyOffice.Web.Models.Currency;
public class CurrencyViewModel: BaseViewModel
{
using Core.Extensions;
using Data.Models.Currencies;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
public class CurrencyViewModel
{
public string Id { get; set; } = null!;
public string Code { get; set; } = null!;
public string Symbol { get; set; } = null!;
public string Name { get; set; } = null!;
public string ShortName { get; set; } = null!;
public decimal? Rate { get; set; }
public int? Quantity { get; set; }
public DateTime? RateDate { get; set; }
public bool IsPrimary { get; set; }
}
public static class CurrencyViewModelExtensions
{
public static CurrencyViewModel ToModel(this Currency input, CurrencyRate? rate = null)
{
return new CurrencyViewModel
{
Id = input.Id.ToShort(),
Code = input.CurrencyGlobal!.Id,
Symbol = input.CurrencyGlobal!.Symbol,
Name = input.Name,
ShortName = input.ShortName,
Quantity = input.CurrentRate?.Quantity ?? rate?.Quantity,
Rate = input.CurrentRate?.Rate ?? rate?.Rate,
RateDate = input.CurrentRate?.DateTime ?? rate?.DateTime,
IsPrimary = input.IsPrimary,
};
}
}
}
public string Id { get; set; } = null!;
public string Code { get; set; } = null!;
public string Symbol { get; set; } = null!;
public string Name { get; set; } = null!;
public string ShortName { get; set; } = null!;
public decimal? Rate { get; set; }
public int? Quantity { get; set; }
public DateTime? RateDate { get; set; }
public bool IsPrimary { get; set; }
}