domBudg/back/Infrastructure/Support/Mappers/SpendingGroupMapper.cs

23 lines
625 B
C#
Raw Normal View History

using Contracts.DTO;
using Infrastructure.Models;
namespace Infrastructure.Support.Mappers;
public static class SpendingGroupMapper
{
public static SpendingGroupDto ToDto(this SpendingGroup group)
=> new()
{
Id = group.Id,
Name = group.Name,
UserId = group.UserId,
ChangeRecords = group.ChangeRecords?.Select(x => x.ToDto()).ToList() ?? []
};
public static SpendingGroup ToModel(this SpendingGroupDto group)
=> new()
{
Id = group.Id,
Name = group.Name,
UserId = group.UserId
};
}