You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OptifitWebService/Server/Mappers/SessionProfile.cs

23 lines
693 B

using AutoMapper;
using System.Linq;
using Infrastructure.Entities;
using Server.Dto.Request;
using Server.Dto.Response;
namespace Server.Mappers
{
public class SessionProfile : Profile
{
public SessionProfile()
{
CreateMap<Session, ResponseSessionDto>()
.ForMember(dest => dest.Duration,
opt => opt.MapFrom(src => src.Exercices.Sum(e => e.Template.Duration)))
.ForMember(dest => dest.Exercices,
opt => opt.MapFrom(src => src.Exercices));
CreateMap<RequestSessionDto, Session>()
.ForMember(dest => dest.Exercices, opt => opt.Ignore());
}
}
}