PlayerManagement/Application/Profiles/MarshalGuardProfile.cs
Tomasi - Developing 35e83c4735 beta 0.0.3
2024-11-26 08:43:01 +01:00

26 lines
1.2 KiB
C#

using Application.DataTransferObjects.MarshalGuard;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class MarshalGuardProfile : Profile
{
public MarshalGuardProfile()
{
CreateMap<MarshalGuard, MarshalGuardDto>()
.ForMember(des => des.Participants, opt => opt.MapFrom(src => src.MarshalGuardParticipants.Count(p => p.Participated)));
CreateMap<MarshalGuard, MarshalGuardDetailDto>()
.ForMember(des => des.Participants, opt => opt.MapFrom(src => src.MarshalGuardParticipants.Count(p => p.Participated)))
.ForMember(des => des.MarshalGuardParticipants, opt => opt.MapFrom(des => des.MarshalGuardParticipants));
CreateMap<UpdateMarshalGuardDto, MarshalGuard>()
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDate)))
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now));
CreateMap<CreateMarshalGuardDto, MarshalGuard>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDate)));
}
}