123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using AutoMapper;
- using Microsoft.AspNetCore.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Core.Global;
- using MTWorkHR.Identity.Entities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MTWorkHR.Application.MappingProfiles
- {
- public class MappingProfile : Profile
- {
- public MappingProfile() {
- //identity user
- CreateMap<UserDto, ApplicationUser>()
- .ForMember(m => m.UserRoles, op => op.Ignore())
- .ForMember(m => m.Id, op => op.Ignore());
- CreateMap<ApplicationUser, UserDto>();
- CreateMap<ApplicationUser, UserAllDto>()
- .ForMember(s => s.ManagerName, o => o.MapFrom(s => s.Manager.FirstName)
-
- //.ForMember(s => s.DepartmentName, o => o.MapFrom(s => GlobalInfo.lang == "ar" ? s.Department.NameAr : s.Department.NameEn)
- );
- CreateMap<UserUpdateDto, ApplicationUser>()
- .ForMember(m => m.UserRoles, op => op.Ignore())
- // .ForMember(m => m.UserBranchs, op => op.Ignore())
- // .ForMember(m => m.UserCycleApprovals, op => op.Ignore())
- //.ForMember(m => m.Hierarchies, op => op.Ignore())
- .ForMember(m => m.Id, op => op.Ignore());
- CreateMap<ApplicationUser, UserUpdateDto>();
- CreateMap<UserAttachmentDto, UserAttachment>().ReverseMap();
- CreateMap<UserAddress, UserAddressDto>().ReverseMap();
- //identity userRoles
- CreateMap<IdentityUserRole<string>, UserRoleDto>().ReverseMap();
- CreateMap<ApplicationRole, UserRoleDto>()
- .ForMember(m => m.RoleId, op => op.MapFrom(mp => mp.Id))
- .ForMember(m => m.RoleName, op => op.MapFrom(mp => mp.Name))
- .ReverseMap();
- //identity role
- CreateMap<RoleDto, ApplicationRole>()
- .ForMember(m => m.Id, op => op.Ignore())
- .ForMember(m => m.RolePermissions, op => op.Ignore())
- ;
- CreateMap<ApplicationRole, RoleDto>();
- CreateMap<RolePermissionDto, RolePermission>().ReverseMap();
-
- }
- }
- }
|