classlib/ExpenseTracker.Application/Accounts/AccountJsonDto.cs
2024-08-07 21:12:02 +03:00

27 lines
805 B
C#

using AutoMapper;
using ExpenseTracker.Application.Common.Mappings;
using ExpenseTracker.Application.Transactions;
using ExpenseTracker.Domain.Entities;
namespace ExpenseTracker.Application.Accounts;
public class AccountJsonDto : IMapFrom<Account>
{
public string Name { get; set; }
public string? Description { get; set; }
public string Currency { get; set; }
public IEnumerable<TransactionJsonDto>? Transactions { get; set; }
public void Mapping(Profile profile)
{
profile.CreateMap<Account, AccountJsonDto>()
.ForMember(d => d.Currency, opt => opt.MapFrom(s => s.Currency.Name));
profile.CreateMap<AccountJsonDto, Account>()
.ForMember(d => d.Currency, opt => opt.MapFrom(s => Domain.Enums.Currency.FromName(s.Currency)));
}
}