12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using AutoMapper;
- using Microsoft.AspNetCore.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Core.Global;
- using MTWorkHR.Identity.Models;
- 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>();
- //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();
- }
- }
- }
|