Files
MetaCourseApi/MetaCourse.Api/Mappings/TopicProfile.cs
T
2026-05-05 10:39:43 +02:00

26 lines
761 B
C#

using AutoMapper;
using MetaCourse.Api.DTOs.Topics;
using MetaCourse.Api.DTOs.Resources;
using MetaCourse.Api.Entities;
namespace MetaCourse.Api.Mappings;
public class TopicProfile : Profile
{
public TopicProfile()
{
CreateMap<Topic, GetTopicDto>()
.ForMember(dest => dest.Resources, opt => opt.MapFrom(
src => src.TopicResources
.OrderBy(tr => tr.Position)
.Select(tr => tr.Resource)));
CreateMap<CreateTopicDto, Topic>()
.ForMember(dest => dest.Id, opt => opt.Ignore());
CreateMap<UpdateTopicDto, Topic>()
.ForMember(dest => dest.Id, opt => opt.Ignore())
.ForMember(dest => dest.CourseId, opt => opt.Ignore());
}
}