PATCH
Refactored DTOs to use AutoMapper instead of manual mapping and made some additional improvements and fixes. Added : GetAllSurveys&DeleteUser.
This commit is contained in:
22
survey-beta/Mappers/Profiles/MappingProfile.cs
Normal file
22
survey-beta/Mappers/Profiles/MappingProfile.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using AutoMapper;
|
||||
using survey_beta.DTOs.Create;
|
||||
using survey_beta.DTOs.Default;
|
||||
using survey_beta.DTOs.Response;
|
||||
using survey_beta.DTOs.Update;
|
||||
using survey_beta.Models;
|
||||
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<CreateSurveyDto, Survey>().ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
CreateMap<CreateQuestionDto, Question>().ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
CreateMap<CreateChoiceDto, Choice>().ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
|
||||
CreateMap<Survey, SurveyDto>();
|
||||
CreateMap<Question, QuestionDto>();
|
||||
CreateMap<Choice, ChoiceDto>();
|
||||
|
||||
CreateMap<UpdateSurveyDto, Survey>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user