using System; using System.Linq.Expressions; using Netina.Domain.Dtos.SmallDtos; using Netina.Domain.Entities.Products; namespace Netina.Domain.Mappers { public static partial class SpecificationMapper { public static Specification AdaptToSpecification(this SpecificationSDto p1) { return p1 == null ? null : new Specification() { Title = p1.Title, Detail = p1.Detail, Value = p1.Value, IsFeature = p1.IsFeature, ProductId = p1.ProductId, ParentId = (Guid?)p1.ParentId, Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Specification AdaptTo(this SpecificationSDto p2, Specification p3) { if (p2 == null) { return null; } Specification result = p3 ?? new Specification(); result.Title = p2.Title; result.Detail = p2.Detail; result.Value = p2.Value; result.IsFeature = p2.IsFeature; result.ProductId = p2.ProductId; result.ParentId = (Guid?)p2.ParentId; result.Id = p2.Id; result.CreatedAt = p2.CreatedAt; return result; } public static SpecificationSDto AdaptToSDto(this Specification p4) { return p4 == null ? null : new SpecificationSDto() { Title = p4.Title, Detail = p4.Detail, Value = p4.Value, IsFeature = p4.IsFeature, ProductId = p4.ProductId, ParentId = p4.ParentId == null ? default(Guid) : (Guid)p4.ParentId, Id = p4.Id, CreatedAt = p4.CreatedAt }; } public static SpecificationSDto AdaptTo(this Specification p5, SpecificationSDto p6) { if (p5 == null) { return null; } SpecificationSDto result = p6 ?? new SpecificationSDto(); result.Title = p5.Title; result.Detail = p5.Detail; result.Value = p5.Value; result.IsFeature = p5.IsFeature; result.ProductId = p5.ProductId; result.ParentId = p5.ParentId == null ? default(Guid) : (Guid)p5.ParentId; result.Id = p5.Id; result.CreatedAt = p5.CreatedAt; return result; } public static Expression> ProjectToSDto => p7 => new SpecificationSDto() { Title = p7.Title, Detail = p7.Detail, Value = p7.Value, IsFeature = p7.IsFeature, ProductId = p7.ProductId, ParentId = p7.ParentId == null ? default(Guid) : (Guid)p7.ParentId, Id = p7.Id, CreatedAt = p7.CreatedAt }; } }