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.

UserMappingProfile.cs 1.1KB

1234567891011121314151617181920212223242526272829
  1. using Diligent.WebAPI.Contracts.DTOs.User;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Diligent.WebAPI.Business.MappingProfiles
  8. {
  9. [ExcludeFromCodeCoverage]
  10. public class UserMappingProfile : Profile
  11. {
  12. public UserMappingProfile()
  13. {
  14. #region DTO to Model
  15. CreateMap<CreateUserRequestDto, User>();
  16. CreateMap<RegisterDTO, User>().ForMember(n => n.PhoneNumber, opt => opt.MapFrom(n => n.Phone));
  17. #endregion
  18. #region Model to DTO
  19. CreateMap<User, UserResponseDTO>();
  20. CreateMap<User, UserDetailsResponseDTO>()
  21. .ForMember(dest => dest.PhoneNumber, opt => opt.NullSubstitute("User has no phone number saved."))
  22. .ForMember(dest => dest.Position, opt => opt.NullSubstitute("Position has not been declared yet."))
  23. .ForMember(dest => dest.LinkedIn, opt => opt.NullSubstitute("User takes no part in any social media."));
  24. #endregion
  25. }
  26. }
  27. }