using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using NetinaShop.Domain.Dtos.LargDtos; using NetinaShop.Domain.Dtos.SmallDtos; 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, BrandId = p1.BrandId, Specifications = funcMain1(p1.Specifications), Reviews = funcMain2(p1.Reviews), Categories = funcMain3(p1.Categories), Files = funcMain4(p1.Files), Id = p1.Id }; } public static Product AdaptTo(this ProductLDto p6, Product p7) { if (p6 == null) { return null; } Product result = p7 ?? new Product(); result.PersianName = p6.PersianName; result.EnglishName = p6.EnglishName; result.Summery = p6.Summery; result.ExpertCheck = p6.ExpertCheck; result.Tags = p6.Tags; result.Warranty = p6.Warranty; result.BrandId = p6.BrandId; result.Specifications = funcMain5(p6.Specifications, result.Specifications); result.Reviews = funcMain6(p6.Reviews, result.Reviews); result.Categories = funcMain7(p6.Categories, result.Categories); result.Files = funcMain8(p6.Files, result.Files); result.Id = p6.Id; return result; } public static Expression> ProjectToProduct => p16 => new Product() { PersianName = p16.PersianName, EnglishName = p16.EnglishName, Summery = p16.Summery, ExpertCheck = p16.ExpertCheck, Tags = p16.Tags, Warranty = p16.Warranty, BrandId = p16.BrandId, Specifications = p16.Specifications.Select(p17 => new Specification() { Title = p17.Title, Detail = p17.Detail, Value = p17.Value, IsFeature = p17.IsFeature, ProductId = p17.ProductId, ParentId = p17.ParentId, Id = p17.Id }).ToList(), Reviews = p16.Reviews.Select(p18 => new Review() { Title = p18.Title, Comment = p18.Comment, Rate = p18.Rate, IsBuyer = p18.IsBuyer, ProductId = p18.ProductId, UserId = p18.UserId, Id = p18.Id }).ToList(), Categories = p16.Categories.Select(p19 => new ProductCategory() { CategoryId = p19.CategoryId, ProductId = p19.ProductId, Id = p19.Id }).ToList(), Files = p16.Files.Select(p20 => new ProductStorageFile() { Name = p20.Name, FileLocation = p20.FileLocation, FileName = p20.FileName, IsHeader = p20.IsHeader, IsPrimary = p20.IsPrimary, FileType = p20.FileType, Id = p20.Id }).ToList(), Id = p16.Id }; public static ProductLDto AdaptToLDto(this Product p21) { return p21 == null ? null : new ProductLDto() { PersianName = p21.PersianName, EnglishName = p21.EnglishName, Summery = p21.Summery, ExpertCheck = p21.ExpertCheck, Tags = p21.Tags, Warranty = p21.Warranty, BrandId = p21.BrandId, Specifications = funcMain9(p21.Specifications), Reviews = funcMain10(p21.Reviews), Categories = funcMain11(p21.Categories), Files = funcMain12(p21.Files), Id = p21.Id }; } public static ProductLDto AdaptTo(this Product p26, ProductLDto p27) { if (p26 == null) { return null; } ProductLDto result = p27 ?? new ProductLDto(); result.PersianName = p26.PersianName; result.EnglishName = p26.EnglishName; result.Summery = p26.Summery; result.ExpertCheck = p26.ExpertCheck; result.Tags = p26.Tags; result.Warranty = p26.Warranty; result.BrandId = p26.BrandId; result.Specifications = funcMain13(p26.Specifications, result.Specifications); result.Reviews = funcMain14(p26.Reviews, result.Reviews); result.Categories = funcMain15(p26.Categories, result.Categories); result.Files = funcMain16(p26.Files, result.Files); result.Id = p26.Id; return result; } public static Expression> ProjectToLDto => p36 => new ProductLDto() { PersianName = p36.PersianName, EnglishName = p36.EnglishName, Summery = p36.Summery, ExpertCheck = p36.ExpertCheck, Tags = p36.Tags, Warranty = p36.Warranty, BrandId = p36.BrandId, Specifications = p36.Specifications.Select(p37 => new SpecificationSDto() { Title = p37.Title, Detail = p37.Detail, Value = p37.Value, IsFeature = p37.IsFeature, ProductId = p37.ProductId, ParentId = p37.ParentId, Id = p37.Id }).ToList(), Reviews = p36.Reviews.Select(p38 => new ReviewSDto() { Title = p38.Title, Comment = p38.Comment, Rate = p38.Rate, IsBuyer = p38.IsBuyer, ProductId = p38.ProductId, UserId = p38.UserId, Id = p38.Id }).ToList(), Categories = p36.Categories.Select(p39 => new ProductCategorySDto() { CategoryId = p39.CategoryId, CategoryName = p39.Category.Name, ProductId = p39.ProductId, Id = p39.Id }).ToList(), Files = p36.Files.Select(p40 => new StorageFileSDto() { Name = p40.Name, FileLocation = p40.FileLocation, FileName = p40.FileName, IsHeader = p40.IsHeader, IsPrimary = p40.IsPrimary, FileType = p40.FileType, Id = p40.Id }).ToList(), Id = p36.Id }; public static Product AdaptToProduct(this ProductSDto p41) { return p41 == null ? null : new Product() { PersianName = p41.PersianName, EnglishName = p41.EnglishName, Summery = p41.Summery, ExpertCheck = p41.ExpertCheck, Tags = p41.Tags, Warranty = p41.Warranty, BrandId = p41.BrandId, Id = p41.Id }; } public static Product AdaptTo(this ProductSDto p42, Product p43) { if (p42 == null) { return null; } Product result = p43 ?? new Product(); result.PersianName = p42.PersianName; result.EnglishName = p42.EnglishName; result.Summery = p42.Summery; result.ExpertCheck = p42.ExpertCheck; result.Tags = p42.Tags; result.Warranty = p42.Warranty; result.BrandId = p42.BrandId; result.Id = p42.Id; return result; } public static ProductSDto AdaptToSDto(this Product p44) { return p44 == null ? null : new ProductSDto() { PersianName = p44.PersianName, EnglishName = p44.EnglishName, Summery = p44.Summery, ExpertCheck = p44.ExpertCheck, Tags = p44.Tags, Warranty = p44.Warranty, BrandId = p44.BrandId, Id = p44.Id }; } public static ProductSDto AdaptTo(this Product p45, ProductSDto p46) { if (p45 == null) { return null; } ProductSDto result = p46 ?? new ProductSDto(); result.PersianName = p45.PersianName; result.EnglishName = p45.EnglishName; result.Summery = p45.Summery; result.ExpertCheck = p45.ExpertCheck; result.Tags = p45.Tags; result.Warranty = p45.Warranty; result.BrandId = p45.BrandId; result.Id = p45.Id; return result; } public static Expression> ProjectToSDto => p47 => new ProductSDto() { PersianName = p47.PersianName, EnglishName = p47.EnglishName, Summery = p47.Summery, ExpertCheck = p47.ExpertCheck, Tags = p47.Tags, Warranty = p47.Warranty, BrandId = p47.BrandId, Id = p47.Id }; 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 = item.ParentId, Id = item.Id }); 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 }); 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) { ProductCategorySDto item = p4[i]; result.Add(item == null ? null : new ProductCategory() { CategoryId = item.CategoryId, ProductId = item.ProductId, Id = item.Id }); i++; } return result; } private static List funcMain4(List p5) { if (p5 == null) { return null; } List result = new List(p5.Count); int i = 0; int len = p5.Count; while (i < len) { StorageFileSDto item = p5[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 }); i++; } return result; } private static List funcMain5(List p8, List p9) { if (p8 == null) { return null; } List result = new List(p8.Count); int i = 0; int len = p8.Count; while (i < len) { SpecificationSDto item = p8[i]; result.Add(item == null ? null : new Specification() { Title = item.Title, Detail = item.Detail, Value = item.Value, IsFeature = item.IsFeature, ProductId = item.ProductId, ParentId = item.ParentId, Id = item.Id }); i++; } return result; } private static List funcMain6(List p10, List p11) { if (p10 == null) { return null; } List result = new List(p10.Count); int i = 0; int len = p10.Count; while (i < len) { ReviewSDto item = p10[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 }); i++; } return result; } private static List funcMain7(List p12, List p13) { if (p12 == null) { return null; } List result = new List(p12.Count); int i = 0; int len = p12.Count; while (i < len) { ProductCategorySDto item = p12[i]; result.Add(item == null ? null : new ProductCategory() { CategoryId = item.CategoryId, ProductId = item.ProductId, Id = item.Id }); i++; } return result; } private static List funcMain8(List p14, List p15) { if (p14 == null) { return null; } List result = new List(p14.Count); int i = 0; int len = p14.Count; while (i < len) { StorageFileSDto item = p14[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 }); i++; } return result; } private static List funcMain9(List p22) { if (p22 == null) { return null; } List result = new List(p22.Count); int i = 0; int len = p22.Count; while (i < len) { Specification item = p22[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, Id = item.Id }); i++; } return result; } private static List funcMain10(List p23) { if (p23 == null) { return null; } List result = new List(p23.Count); int i = 0; int len = p23.Count; while (i < len) { Review item = p23[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 }); i++; } return result; } private static List funcMain11(List p24) { if (p24 == null) { return null; } List result = new List(p24.Count); int i = 0; int len = p24.Count; while (i < len) { ProductCategory item = p24[i]; result.Add(item == null ? null : new ProductCategorySDto() { CategoryId = item.CategoryId, CategoryName = item.Category == null ? null : item.Category.Name, ProductId = item.ProductId, Id = item.Id }); i++; } return result; } private static List funcMain12(List p25) { if (p25 == null) { return null; } List result = new List(p25.Count); int i = 0; int len = p25.Count; while (i < len) { ProductStorageFile item = p25[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 funcMain13(List p28, List p29) { if (p28 == null) { return null; } List result = new List(p28.Count); int i = 0; int len = p28.Count; while (i < len) { Specification item = p28[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, Id = item.Id }); i++; } return result; } private static List funcMain14(List p30, List p31) { if (p30 == null) { return null; } List result = new List(p30.Count); int i = 0; int len = p30.Count; while (i < len) { Review item = p30[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 }); i++; } return result; } private static List funcMain15(List p32, List p33) { if (p32 == null) { return null; } List result = new List(p32.Count); int i = 0; int len = p32.Count; while (i < len) { ProductCategory item = p32[i]; result.Add(item == null ? null : new ProductCategorySDto() { CategoryId = item.CategoryId, CategoryName = item.Category == null ? null : item.Category.Name, ProductId = item.ProductId, Id = item.Id }); i++; } return result; } private static List funcMain16(List p34, List p35) { if (p34 == null) { return null; } List result = new List(p34.Count); int i = 0; int len = p34.Count; while (i < len) { ProductStorageFile item = p34[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; } } }