using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Mapster.Models; using NetinaShop.Domain.Dtos.LargDtos; using NetinaShop.Domain.Dtos.SmallDtos; using NetinaShop.Domain.Entities.Brands; using NetinaShop.Domain.Entities.ProductCategories; using NetinaShop.Domain.Entities.Products; namespace NetinaShop.Domain.Mappers { public static partial class ProductMapper { public static Product AdaptToProduct(this ProductLDto p1) { return p1 == null ? null : new Product() { PersianName = p1.PersianName, EnglishName = p1.EnglishName, Summery = p1.Summery, ExpertCheck = p1.ExpertCheck, Tags = p1.Tags, Warranty = p1.Warranty, Cost = p1.Cost, BeDisplayed = p1.BeDisplayed, PackingCost = p1.PackingCost, Stock = p1.Stock, HasExpressDelivery = p1.HasExpressDelivery, MaxOrderCount = p1.MaxOrderCount, BrandId = p1.BrandId, CategoryId = p1.CategoryId, Specifications = funcMain1(p1.Specifications), Reviews = funcMain2(p1.Reviews), Files = funcMain3(p1.Files), Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Product AdaptTo(this ProductLDto p5, Product p6) { if (p5 == null) { return null; } Product result = p6 ?? new Product(); result.PersianName = p5.PersianName; result.EnglishName = p5.EnglishName; result.Summery = p5.Summery; result.ExpertCheck = p5.ExpertCheck; result.Tags = p5.Tags; result.Warranty = p5.Warranty; result.Cost = p5.Cost; result.BeDisplayed = p5.BeDisplayed; result.PackingCost = p5.PackingCost; result.Stock = p5.Stock; result.HasExpressDelivery = p5.HasExpressDelivery; result.MaxOrderCount = p5.MaxOrderCount; result.BrandId = p5.BrandId; result.CategoryId = p5.CategoryId; result.Specifications = funcMain4(p5.Specifications, result.Specifications); result.Reviews = funcMain5(p5.Reviews, result.Reviews); result.Files = funcMain6(p5.Files, result.Files); result.Id = p5.Id; result.CreatedAt = p5.CreatedAt; return result; } public static Expression> ProjectToProduct => p13 => new Product() { PersianName = p13.PersianName, EnglishName = p13.EnglishName, Summery = p13.Summery, ExpertCheck = p13.ExpertCheck, Tags = p13.Tags, Warranty = p13.Warranty, Cost = p13.Cost, BeDisplayed = p13.BeDisplayed, PackingCost = p13.PackingCost, Stock = p13.Stock, HasExpressDelivery = p13.HasExpressDelivery, MaxOrderCount = p13.MaxOrderCount, BrandId = p13.BrandId, CategoryId = p13.CategoryId, Specifications = p13.Specifications.Select(p14 => new Specification() { Title = p14.Title, Detail = p14.Detail, Value = p14.Value, IsFeature = p14.IsFeature, ProductId = p14.ProductId, ParentId = (Guid?)p14.ParentId, Id = p14.Id, CreatedAt = p14.CreatedAt }).ToList(), Reviews = p13.Reviews.Select(p15 => new Review() { Title = p15.Title, Comment = p15.Comment, Rate = p15.Rate, IsBuyer = p15.IsBuyer, ProductId = p15.ProductId, UserId = p15.UserId, Id = p15.Id, CreatedAt = p15.CreatedAt }).ToList(), Files = p13.Files.Select(p16 => new ProductStorageFile() { Name = p16.Name, FileLocation = p16.FileLocation, FileName = p16.FileName, IsHeader = p16.IsHeader, IsPrimary = p16.IsPrimary, FileType = p16.FileType, Id = p16.Id, CreatedAt = p16.CreatedAt }).ToList(), Id = p13.Id, CreatedAt = p13.CreatedAt }; public static ProductLDto AdaptToLDto(this Product p17) { return p17 == null ? null : new ProductLDto() { PersianName = p17.PersianName, EnglishName = p17.EnglishName, Summery = p17.Summery, ExpertCheck = p17.ExpertCheck, Tags = p17.Tags, Warranty = p17.Warranty, BeDisplayed = p17.BeDisplayed, HasExpressDelivery = p17.HasExpressDelivery, MaxOrderCount = p17.MaxOrderCount, Cost = p17.Cost, PackingCost = p17.PackingCost, Stock = p17.Stock, BrandId = p17.BrandId, BrandName = p17.Brand == null ? null : p17.Brand.Name, CategoryId = p17.CategoryId, CategoryName = p17.Category == null ? null : p17.Category.Name, Specifications = funcMain7(p17.Specifications), Reviews = funcMain8(p17.Reviews), Files = funcMain9(p17.Files), Id = p17.Id, CreatedAt = p17.CreatedAt }; } public static ProductLDto AdaptTo(this Product p21, ProductLDto p22) { if (p21 == null) { return null; } ProductLDto result = p22 ?? new ProductLDto(); result.PersianName = p21.PersianName; result.EnglishName = p21.EnglishName; result.Summery = p21.Summery; result.ExpertCheck = p21.ExpertCheck; result.Tags = p21.Tags; result.Warranty = p21.Warranty; result.BeDisplayed = p21.BeDisplayed; result.HasExpressDelivery = p21.HasExpressDelivery; result.MaxOrderCount = p21.MaxOrderCount; result.Cost = p21.Cost; result.PackingCost = p21.PackingCost; result.Stock = p21.Stock; result.BrandId = p21.BrandId; result.BrandName = p21.Brand == null ? null : p21.Brand.Name; result.CategoryId = p21.CategoryId; result.CategoryName = p21.Category == null ? null : p21.Category.Name; result.Specifications = funcMain10(p21.Specifications, result.Specifications); result.Reviews = funcMain11(p21.Reviews, result.Reviews); result.Files = funcMain12(p21.Files, result.Files); result.Id = p21.Id; result.CreatedAt = p21.CreatedAt; return result; } public static Expression> ProjectToLDto => p29 => new ProductLDto() { PersianName = p29.PersianName, EnglishName = p29.EnglishName, Summery = p29.Summery, ExpertCheck = p29.ExpertCheck, Tags = p29.Tags, Warranty = p29.Warranty, BeDisplayed = p29.BeDisplayed, HasExpressDelivery = p29.HasExpressDelivery, MaxOrderCount = p29.MaxOrderCount, Cost = p29.Cost, PackingCost = p29.PackingCost, Stock = p29.Stock, BrandId = p29.BrandId, BrandName = p29.Brand.Name, CategoryId = p29.CategoryId, CategoryName = p29.Category.Name, Specifications = p29.Specifications.Select(p30 => new SpecificationSDto() { Title = p30.Title, Detail = p30.Detail, Value = p30.Value, IsFeature = p30.IsFeature, ProductId = p30.ProductId, ParentId = p30.ParentId == null ? default(Guid) : (Guid)p30.ParentId, Id = p30.Id, CreatedAt = p30.CreatedAt }).ToList(), Reviews = p29.Reviews.Select(p31 => new ReviewSDto() { Title = p31.Title, Comment = p31.Comment, Rate = p31.Rate, IsBuyer = p31.IsBuyer, ProductId = p31.ProductId, UserId = p31.UserId, Id = p31.Id, CreatedAt = p31.CreatedAt }).ToList(), Files = p29.Files.Select(p32 => new StorageFileSDto() { Name = p32.Name, FileLocation = p32.FileLocation, FileName = p32.FileName, IsHeader = p32.IsHeader, IsPrimary = p32.IsPrimary, FileType = p32.FileType, Id = p32.Id }).ToList(), Id = p29.Id, CreatedAt = p29.CreatedAt }; public static Product AdaptToProduct(this ProductSDto p33) { return p33 == null ? null : new Product() { PersianName = p33.PersianName, EnglishName = p33.EnglishName, Summery = p33.Summery, ExpertCheck = p33.ExpertCheck, Tags = p33.Tags, Warranty = p33.Warranty, Cost = p33.Cost, IsEnable = p33.IsEnable, BeDisplayed = p33.BeDisplayed, PackingCost = p33.PackingCost, Rate = p33.Rate, ReviewCount = p33.ReviewCount, Viewed = p33.Viewed, BrandId = p33.BrandId, Brand = new Brand() { Name = p33.BrandName, Id = p33.BrandId }, CategoryId = p33.CategoryId, Category = new ProductCategory() { Name = p33.CategoryName, Id = p33.CategoryId }, Id = p33.Id, CreatedAt = p33.CreatedAt }; } public static Product AdaptTo(this ProductSDto p34, Product p35) { if (p34 == null) { return null; } Product result = p35 ?? new Product(); result.PersianName = p34.PersianName; result.EnglishName = p34.EnglishName; result.Summery = p34.Summery; result.ExpertCheck = p34.ExpertCheck; result.Tags = p34.Tags; result.Warranty = p34.Warranty; result.Cost = p34.Cost; result.IsEnable = p34.IsEnable; result.BeDisplayed = p34.BeDisplayed; result.PackingCost = p34.PackingCost; result.Rate = p34.Rate; result.ReviewCount = p34.ReviewCount; result.Viewed = p34.Viewed; result.BrandId = p34.BrandId; result.Brand = funcMain13(new Never(), result.Brand, p34); result.CategoryId = p34.CategoryId; result.Category = funcMain14(new Never(), result.Category, p34); result.Id = p34.Id; result.CreatedAt = p34.CreatedAt; return result; } public static ProductSDto AdaptToSDto(this Product p40) { return p40 == null ? null : new ProductSDto() { PersianName = p40.PersianName, EnglishName = p40.EnglishName, Summery = p40.Summery, ExpertCheck = p40.ExpertCheck, Tags = p40.Tags, Warranty = p40.Warranty, Cost = p40.Cost, IsEnable = p40.IsEnable, BeDisplayed = p40.BeDisplayed, PackingCost = p40.PackingCost, Rate = p40.Rate, ReviewCount = p40.ReviewCount, Viewed = p40.Viewed, CategoryId = p40.CategoryId, BrandId = p40.BrandId, BrandName = p40.Brand == null ? null : p40.Brand.Name, CategoryName = p40.Category == null ? null : p40.Category.Name, Id = p40.Id, CreatedAt = p40.CreatedAt }; } public static ProductSDto AdaptTo(this Product p41, ProductSDto p42) { if (p41 == null) { return null; } ProductSDto result = p42 ?? new ProductSDto(); result.PersianName = p41.PersianName; result.EnglishName = p41.EnglishName; result.Summery = p41.Summery; result.ExpertCheck = p41.ExpertCheck; result.Tags = p41.Tags; result.Warranty = p41.Warranty; result.Cost = p41.Cost; result.IsEnable = p41.IsEnable; result.BeDisplayed = p41.BeDisplayed; result.PackingCost = p41.PackingCost; result.Rate = p41.Rate; result.ReviewCount = p41.ReviewCount; result.Viewed = p41.Viewed; result.CategoryId = p41.CategoryId; result.BrandId = p41.BrandId; result.BrandName = p41.Brand == null ? null : p41.Brand.Name; result.CategoryName = p41.Category == null ? null : p41.Category.Name; result.Id = p41.Id; result.CreatedAt = p41.CreatedAt; return result; } public static Expression> ProjectToSDto => p43 => new ProductSDto() { PersianName = p43.PersianName, EnglishName = p43.EnglishName, Summery = p43.Summery, ExpertCheck = p43.ExpertCheck, Tags = p43.Tags, Warranty = p43.Warranty, Cost = p43.Cost, IsEnable = p43.IsEnable, BeDisplayed = p43.BeDisplayed, PackingCost = p43.PackingCost, Rate = p43.Rate, ReviewCount = p43.ReviewCount, Viewed = p43.Viewed, CategoryId = p43.CategoryId, BrandId = p43.BrandId, BrandName = p43.Brand == null ? null : p43.Brand.Name, CategoryName = p43.Category == null ? null : p43.Category.Name, Id = p43.Id, CreatedAt = p43.CreatedAt }; private static List funcMain1(List p2) { if (p2 == null) { return null; } List result = new List(p2.Count); int i = 0; int len = p2.Count; while (i < len) { SpecificationSDto item = p2[i]; result.Add(item == null ? null : new Specification() { Title = item.Title, Detail = item.Detail, Value = item.Value, IsFeature = item.IsFeature, ProductId = item.ProductId, ParentId = (Guid?)item.ParentId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain2(List p3) { if (p3 == null) { return null; } List result = new List(p3.Count); int i = 0; int len = p3.Count; while (i < len) { ReviewSDto item = p3[i]; result.Add(item == null ? null : new Review() { Title = item.Title, Comment = item.Comment, Rate = item.Rate, IsBuyer = item.IsBuyer, ProductId = item.ProductId, UserId = item.UserId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain3(List p4) { if (p4 == null) { return null; } List result = new List(p4.Count); int i = 0; int len = p4.Count; while (i < len) { StorageFileSDto item = p4[i]; result.Add(item == null ? null : new ProductStorageFile() { Name = item.Name, FileLocation = item.FileLocation, FileName = item.FileName, IsHeader = item.IsHeader, IsPrimary = item.IsPrimary, FileType = item.FileType, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain4(List p7, List p8) { if (p7 == null) { return null; } List result = new List(p7.Count); int i = 0; int len = p7.Count; while (i < len) { SpecificationSDto item = p7[i]; result.Add(item == null ? null : new Specification() { Title = item.Title, Detail = item.Detail, Value = item.Value, IsFeature = item.IsFeature, ProductId = item.ProductId, ParentId = (Guid?)item.ParentId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain5(List p9, List p10) { if (p9 == null) { return null; } List result = new List(p9.Count); int i = 0; int len = p9.Count; while (i < len) { ReviewSDto item = p9[i]; result.Add(item == null ? null : new Review() { Title = item.Title, Comment = item.Comment, Rate = item.Rate, IsBuyer = item.IsBuyer, ProductId = item.ProductId, UserId = item.UserId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain6(List p11, List p12) { if (p11 == null) { return null; } List result = new List(p11.Count); int i = 0; int len = p11.Count; while (i < len) { StorageFileSDto item = p11[i]; result.Add(item == null ? null : new ProductStorageFile() { Name = item.Name, FileLocation = item.FileLocation, FileName = item.FileName, IsHeader = item.IsHeader, IsPrimary = item.IsPrimary, FileType = item.FileType, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain7(List p18) { if (p18 == null) { return null; } List result = new List(p18.Count); int i = 0; int len = p18.Count; while (i < len) { Specification item = p18[i]; result.Add(item == null ? null : new SpecificationSDto() { Title = item.Title, Detail = item.Detail, Value = item.Value, IsFeature = item.IsFeature, ProductId = item.ProductId, ParentId = item.ParentId == null ? default(Guid) : (Guid)item.ParentId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain8(List p19) { if (p19 == null) { return null; } List result = new List(p19.Count); int i = 0; int len = p19.Count; while (i < len) { Review item = p19[i]; result.Add(item == null ? null : new ReviewSDto() { Title = item.Title, Comment = item.Comment, Rate = item.Rate, IsBuyer = item.IsBuyer, ProductId = item.ProductId, UserId = item.UserId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain9(List p20) { if (p20 == null) { return null; } List result = new List(p20.Count); int i = 0; int len = p20.Count; while (i < len) { ProductStorageFile item = p20[i]; result.Add(item == null ? null : new StorageFileSDto() { Name = item.Name, FileLocation = item.FileLocation, FileName = item.FileName, IsHeader = item.IsHeader, IsPrimary = item.IsPrimary, FileType = item.FileType, Id = item.Id }); i++; } return result; } private static List funcMain10(List p23, List p24) { if (p23 == null) { return null; } List result = new List(p23.Count); int i = 0; int len = p23.Count; while (i < len) { Specification item = p23[i]; result.Add(item == null ? null : new SpecificationSDto() { Title = item.Title, Detail = item.Detail, Value = item.Value, IsFeature = item.IsFeature, ProductId = item.ProductId, ParentId = item.ParentId == null ? default(Guid) : (Guid)item.ParentId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain11(List p25, List p26) { if (p25 == null) { return null; } List result = new List(p25.Count); int i = 0; int len = p25.Count; while (i < len) { Review item = p25[i]; result.Add(item == null ? null : new ReviewSDto() { Title = item.Title, Comment = item.Comment, Rate = item.Rate, IsBuyer = item.IsBuyer, ProductId = item.ProductId, UserId = item.UserId, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain12(List p27, List p28) { if (p27 == null) { return null; } List result = new List(p27.Count); int i = 0; int len = p27.Count; while (i < len) { ProductStorageFile item = p27[i]; result.Add(item == null ? null : new StorageFileSDto() { Name = item.Name, FileLocation = item.FileLocation, FileName = item.FileName, IsHeader = item.IsHeader, IsPrimary = item.IsPrimary, FileType = item.FileType, Id = item.Id }); i++; } return result; } private static Brand funcMain13(Never p36, Brand p37, ProductSDto p34) { Brand result = p37 ?? new Brand(); result.Name = p34.BrandName; result.Id = p34.BrandId; return result; } private static ProductCategory funcMain14(Never p38, ProductCategory p39, ProductSDto p34) { ProductCategory result = p39 ?? new ProductCategory(); result.Name = p34.CategoryName; result.Id = p34.CategoryId; return result; } } }