using System; using System.Linq.Expressions; using NetinaShop.Domain.Dtos.SmallDtos; using NetinaShop.Domain.Entities.Users; using NetinaShop.Domain.Enums; namespace NetinaShop.Domain.Mappers { public static partial class ManagerMapper { public static Manager AdaptToManager(this ManagerSDto p1) { return p1 == null ? null : new Manager() { LatestVersionUsed = p1.LatestVersionUsed, Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Manager AdaptTo(this ManagerSDto p2, Manager p3) { if (p2 == null) { return null; } Manager result = p3 ?? new Manager(); result.LatestVersionUsed = p2.LatestVersionUsed; result.Id = p2.Id; result.CreatedAt = p2.CreatedAt; return result; } public static ManagerSDto AdaptToSDto(this Manager p4) { return p4 == null ? null : new ManagerSDto() { PhoneNumber = p4.User != null ? p4.User.PhoneNumber : string.Empty, FirstName = p4.User != null ? p4.User.FirstName : string.Empty, LastName = p4.User != null ? p4.User.LastName : string.Empty, BirthDate = p4.User != null ? p4.User.BirthDate : DateTime.MinValue, Gender = p4.User != null ? p4.User.Gender : Gender.Male, SignUpStatus = p4.User != null ? p4.User.SignUpStatus : SignUpStatus.StartSignOn, NationalId = p4.User != null ? p4.User.NationalId : string.Empty, Email = p4.User != null ? p4.User.Email : string.Empty, LatestVersionUsed = p4.LatestVersionUsed, Id = p4.Id, CreatedAt = p4.CreatedAt }; } public static ManagerSDto AdaptTo(this Manager p5, ManagerSDto p6) { if (p5 == null) { return null; } ManagerSDto result = p6 ?? new ManagerSDto(); result.PhoneNumber = p5.User != null ? p5.User.PhoneNumber : string.Empty; result.FirstName = p5.User != null ? p5.User.FirstName : string.Empty; result.LastName = p5.User != null ? p5.User.LastName : string.Empty; result.BirthDate = p5.User != null ? p5.User.BirthDate : DateTime.MinValue; result.Gender = p5.User != null ? p5.User.Gender : Gender.Male; result.SignUpStatus = p5.User != null ? p5.User.SignUpStatus : SignUpStatus.StartSignOn; result.NationalId = p5.User != null ? p5.User.NationalId : string.Empty; result.Email = p5.User != null ? p5.User.Email : string.Empty; result.LatestVersionUsed = p5.LatestVersionUsed; result.Id = p5.Id; result.CreatedAt = p5.CreatedAt; return result; } public static Expression> ProjectToSDto => p7 => new ManagerSDto() { PhoneNumber = p7.User != null ? p7.User.PhoneNumber : string.Empty, FirstName = p7.User != null ? p7.User.FirstName : string.Empty, LastName = p7.User != null ? p7.User.LastName : string.Empty, BirthDate = p7.User != null ? p7.User.BirthDate : DateTime.MinValue, Gender = p7.User != null ? p7.User.Gender : Gender.Male, SignUpStatus = p7.User != null ? p7.User.SignUpStatus : SignUpStatus.StartSignOn, NationalId = p7.User != null ? p7.User.NationalId : string.Empty, Email = p7.User != null ? p7.User.Email : string.Empty, LatestVersionUsed = p7.LatestVersionUsed, Id = p7.Id, CreatedAt = p7.CreatedAt }; } }