Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user