using System; using System.Linq.Expressions; using DocuMed.Domain.Dtos.SmallDtos; using DocuMed.Domain.Entities.City; using DocuMed.Domain.Entities.User; using Mapster.Models; namespace DocuMed.Domain.Mappers { public static partial class ApplicationUserMapper { public static ApplicationUser AdaptToApplicationUser(this ApplicationUserSDto p1) { return p1 == null ? null : new ApplicationUser() { FirstName = p1.FirstName, LastName = p1.LastName, NationalId = p1.NationalId, StudentId = p1.StudentId, BirthDate = p1.BirthDate, Gender = p1.Gender, SignUpStatus = p1.SignUpStatus, UniversityId = (Guid?)p1.UniversityId, University = new University() {Id = p1.UniversityId}, SectionId = (Guid?)p1.SectionId, Section = new Section() { Name = p1.SectionName, Id = p1.SectionId }, Id = p1.Id, UserName = p1.UserName, Email = p1.Email, PhoneNumber = p1.PhoneNumber, PhoneNumberConfirmed = p1.PhoneNumberConfirmed }; } public static ApplicationUser AdaptTo(this ApplicationUserSDto p2, ApplicationUser p3) { if (p2 == null) { return null; } ApplicationUser result = p3 ?? new ApplicationUser(); result.FirstName = p2.FirstName; result.LastName = p2.LastName; result.NationalId = p2.NationalId; result.StudentId = p2.StudentId; result.BirthDate = p2.BirthDate; result.Gender = p2.Gender; result.SignUpStatus = p2.SignUpStatus; result.UniversityId = (Guid?)p2.UniversityId; result.University = funcMain1(new Never(), result.University, p2); result.SectionId = (Guid?)p2.SectionId; result.Section = funcMain2(new Never(), result.Section, p2); result.Id = p2.Id; result.UserName = p2.UserName; result.Email = p2.Email; result.PhoneNumber = p2.PhoneNumber; result.PhoneNumberConfirmed = p2.PhoneNumberConfirmed; return result; } public static Expression> ProjectToApplicationUser => p8 => new ApplicationUser() { FirstName = p8.FirstName, LastName = p8.LastName, NationalId = p8.NationalId, StudentId = p8.StudentId, BirthDate = p8.BirthDate, Gender = p8.Gender, SignUpStatus = p8.SignUpStatus, UniversityId = (Guid?)p8.UniversityId, University = new University() {Id = p8.UniversityId}, SectionId = (Guid?)p8.SectionId, Section = new Section() { Name = p8.SectionName, Id = p8.SectionId }, Id = p8.Id, UserName = p8.UserName, Email = p8.Email, PhoneNumber = p8.PhoneNumber, PhoneNumberConfirmed = p8.PhoneNumberConfirmed }; public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p9) { return p9 == null ? null : new ApplicationUserSDto() { FirstName = p9.FirstName, LastName = p9.LastName, UserName = p9.UserName, Email = p9.Email, PhoneNumber = p9.PhoneNumber, PhoneNumberConfirmed = p9.PhoneNumberConfirmed, NationalId = p9.NationalId, StudentId = p9.StudentId, BirthDate = p9.BirthDate, Gender = p9.Gender, SignUpStatus = p9.SignUpStatus, UniversityId = p9.UniversityId == null ? default(Guid) : (Guid)p9.UniversityId, SectionId = p9.SectionId == null ? default(Guid) : (Guid)p9.SectionId, SectionName = p9.Section != null ? p9.Section.Name : string.Empty, Id = p9.Id }; } public static ApplicationUserSDto AdaptTo(this ApplicationUser p10, ApplicationUserSDto p11) { if (p10 == null) { return null; } ApplicationUserSDto result = p11 ?? new ApplicationUserSDto(); result.FirstName = p10.FirstName; result.LastName = p10.LastName; result.UserName = p10.UserName; result.Email = p10.Email; result.PhoneNumber = p10.PhoneNumber; result.PhoneNumberConfirmed = p10.PhoneNumberConfirmed; result.NationalId = p10.NationalId; result.StudentId = p10.StudentId; result.BirthDate = p10.BirthDate; result.Gender = p10.Gender; result.SignUpStatus = p10.SignUpStatus; result.UniversityId = p10.UniversityId == null ? default(Guid) : (Guid)p10.UniversityId; result.SectionId = p10.SectionId == null ? default(Guid) : (Guid)p10.SectionId; result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty; result.Id = p10.Id; return result; } public static Expression> ProjectToSDto => p12 => new ApplicationUserSDto() { FirstName = p12.FirstName, LastName = p12.LastName, UserName = p12.UserName, Email = p12.Email, PhoneNumber = p12.PhoneNumber, PhoneNumberConfirmed = p12.PhoneNumberConfirmed, NationalId = p12.NationalId, StudentId = p12.StudentId, BirthDate = p12.BirthDate, Gender = p12.Gender, SignUpStatus = p12.SignUpStatus, UniversityId = p12.UniversityId == null ? default(Guid) : (Guid)p12.UniversityId, SectionId = p12.SectionId == null ? default(Guid) : (Guid)p12.SectionId, SectionName = p12.Section != null ? p12.Section.Name : string.Empty, Id = p12.Id }; private static University funcMain1(Never p4, University p5, ApplicationUserSDto p2) { University result = p5 ?? new University(); result.Id = p2.UniversityId; return result; } private static Section funcMain2(Never p6, Section p7, ApplicationUserSDto p2) { Section result = p7 ?? new Section(); result.Name = p2.SectionName; result.Id = p2.SectionId; return result; } } }