Files
WorkFlowCheck/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs
T

52 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper.Configuration.Conventions;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.DL.Entities;
namespace WorkFlowCheck.BL.Mappings
{
public class MapperProfile : Profile
{
public MapperProfile()
{
CreateMap<User, UserDTO>().ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.UserRoles.Select(ur => ur.Role)));
CreateMap<Role, RoleDTO>();
CreateMap<UserRole, UserRoleDTO>()
.ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.Role))
.ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User));
CreateMap<UserDTO, User>()
.ForMember(dest => dest.PasswordHash, opt => opt.MapFrom<PasswordHashResolver>());
CreateMap<CheckListTemplateHeader, CheckListTemplateHeaderDTO>()
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
CreateMap<CheckListTemplateRow, CheckListTemplateRowDTO>()
.ForMember(dest => dest.EquipmentDTO, opt => opt.MapFrom(src => src.Equipment))
.ForMember(dest => dest.CheckPointDTO, opt => opt.MapFrom(src => src.CheckPoint));
CreateMap<CheckPoint, CheckPointDTO>().ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
CreateMap<CheckPointDTO, CheckPoint>();
CreateMap<Location, LocationDTO>();
CreateMap<LocationDTO, Location>();
CreateMap<Equipment, EquipmentDTO>();
CreateMap<EquipmentDTO, Equipment>();
CreateMap<CheckListHeader, CheckListHeaderDTO>()
.ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User))
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
}
}
}