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

27 lines
1.1 KiB
C#

using Application.DataTransferObjects.DesertStorm;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class DesertStormProfile : Profile
{
public DesertStormProfile()
{
CreateMap<DesertStorm, DesertStormDto>()
.ForMember(des => des.Participants,
opt => opt.MapFrom(src => src.DesertStormParticipants.Count(p => p.Participated)));
CreateMap<DesertStorm, DesertStormDetailDto>()
.ForMember(des => des.DesertStormParticipants, opt => opt.MapFrom(src => src.DesertStormParticipants))
.ForMember(des => des.Participants,
opt => opt.MapFrom(src => src.DesertStormParticipants.Count(p => p.Participated)));
CreateMap<UpdateDesertStormDto, DesertStorm>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now));
CreateMap<CreateDesertStormDto, DesertStorm>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDate)));
}
}