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

28 lines
750 B
C#

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