123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using AutoMapper;
- using Countries.NET;
- using Microsoft.AspNetCore.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Core.Entities;
- using MTWorkHR.Core.Entities.User;
- using MTWorkHR.Core.Global;
- using MTWorkHR.Infrastructure.Entities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MTWorkHR.Application.Mapper
- {
- 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>().ForMember(m => m.Password, op => op.Ignore());
- CreateMap<ApplicationUser, UserAllDto>()
- .ForMember(s => s.QualificationName, o => o.MapFrom(s => s.Qualification ==null ? "" : GlobalInfo.lang == "ar" ? s.Qualification.NameAr : s.Qualification.NameEn))
- .ForMember(s => s.JobTitleName, o => o.MapFrom(s => s.JobTitle ==null ? "" : GlobalInfo.lang == "ar" ? s.JobTitle.NameAr : s.JobTitle.NameEn))
- .ForMember(s => s.IndustryName, o => o.MapFrom(s => s.Industry ==null ? "" : GlobalInfo.lang == "ar" ? s.Industry.NameAr : s.Industry.NameEn))
- .ForMember(s => s.CountryName, o => o.MapFrom(s => s.Country ==null ? "" : GlobalInfo.lang == "ar" ? s.Country.NameAr : s.Country.NameEn))
- .ForMember(s => s.UniversityName, o => o.MapFrom(s => s.University == null ? "" : GlobalInfo.lang == "ar" ? s.University.NameAr : s.University.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<AttachmentDto, 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();
- CreateMap<ProjectDto, Project>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()).ReverseMap();
- CreateMap<UserTaskDto, UserTask>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()).ReverseMap();
- CreateMap<UserTaskAttachment, AttachmentDto>().ReverseMap();
- CreateMap<UserTaskHistoryDto, UserTaskHistory>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
- CreateMap<Team, TeamDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
- CreateMap<TeamUserDto, TeamUser>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
- CreateMap<Meeting, MeetingDto>();
- CreateMap<MeetingDto , Meeting>()
- .ForMember(d => d.CreateDate, o => o.Ignore())
- .ForMember(d => d.CreateUser, o => o.Ignore());
- CreateMap<MeetingUser, MeetingUserDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
- CreateMap<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek)).ReverseMap()
- .ForMember(d => d.CreateDate, o => o.Ignore());
- CreateMap<OrderAllocation, OrderAllocationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
- CreateMap<OrderRequest, OrderRequestDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
- CreateMap<OrderType, OrderTypeDto>().ReverseMap();
- CreateMap<LeaveType, LeaveTypeDto>().ReverseMap();
- CreateMap<CompanyDto, Company>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
- CreateMap<Company, CompanyDto>();
- CreateMap<CountryLookup, CountryDto>().ReverseMap();
- CreateMap<Industry, IndustryDto>().ReverseMap();
- CreateMap<JobTitle, JobTitleDto>().ReverseMap();
- CreateMap<University, UniversityDto>().ReverseMap();
- CreateMap<Qualification, QualificationDto>().ReverseMap();
- CreateMap<City, CityDto>().ReverseMap();
- CreateMap<UserDto, CompanyUserDto>();
- CreateMap<CompanyUserDto, UserDto>().ForMember(m => m.UserName, o => o.MapFrom(s => s.Email)).ReverseMap();
- CreateMap<CompanyUserDto, ApplicationUser>()
- .ForMember(m => m.UserRoles, op => op.Ignore())
- .ForMember(m => m.Id, op => op.Ignore());
- CreateMap<CompanyUserDto, ApplicationUser>().ForMember(m => m.UserName, o => o.MapFrom(s => s.Email));
- CreateMap<ApplicationUser, CompanyUserDto>().ForMember(m => m.Password, op => op.Ignore());
- CreateMap<UserTaskStatus, UserTaskStatusDto>().ReverseMap();
- }
- }
- }
|