36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
namespace MyOffice.Web.Models.Currency;
|
|
|
|
using AutoMapper;
|
|
using MyOffice.Services.Currency.Domain;
|
|
|
|
public class CurrencyViewModel: BaseViewModel
|
|
{
|
|
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 class CurrencyViewModelProfile: Profile
|
|
{
|
|
public CurrencyViewModelProfile()
|
|
{
|
|
CreateMap<CurrencyDto, CurrencyViewModel>();
|
|
|
|
CreateMap<CurrencyWithRateDto, CurrencyViewModel>()
|
|
.ForMember(x => x.Id, o => o.MapFrom(x => x.Currency.Id))
|
|
.ForMember(x => x.Code, o => o.MapFrom(x => x.Currency.CurrencyGlobalId))
|
|
.ForMember(x => x.Name, o => o.MapFrom(x => x.Currency.Name))
|
|
.ForMember(x => x.ShortName, o => o.MapFrom(x => x.Currency.ShortName))
|
|
.ForMember(x => x.Rate, o => o.MapFrom(x => x.Rate == null ? (decimal?)null : x.Rate.Rate))
|
|
.ForMember(x => x.IsPrimary, o => o.MapFrom(x => x.Currency.IsPrimary))
|
|
.ForMember(x => x.Quantity, o => o.MapFrom(x => x.Rate == null ? (int?)null : x.Rate.Quantity))
|
|
.ForMember(x => x.RateDate, o => o.MapFrom(x => x.Rate == null ? (DateTime?)null : x.Rate.DateTime))
|
|
;
|
|
}
|
|
} |