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

30 lines
830 B
C#

using AutoMapper;
using ExpenseTracker.Application.Common.Mappings;
using ExpenseTracker.Domain.Entities;
namespace ExpenseTracker.Application.Transactions;
public class TransactionDto : IMapFrom<Transaction>
{
public string Id { get; set; }
public double Amount { get; set; }
public string Category { get; set; }
public DateTimeOffset Time { get; set; }
public string? Description { get; set; }
public string? AccountId { get; set; }
public void Mapping(Profile profile)
{
profile.CreateMap<Transaction, TransactionDto>()
.ForMember(d => d.Category, opt => opt.MapFrom(s => s.Category.Name));
profile.CreateMap<TransactionDto, Transaction>()
.ForMember(d => d.Category, opt => opt.MapFrom(s => Domain.Enums.Category.FromName(s.Category)));
}
}