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.Brands; namespace NetinaShop.Domain.Mappers { public static partial class BrandMapper { public static Brand AdaptToBrand(this BrandLDto p1) { return p1 == null ? null : new Brand() { PersianName = p1.PersianName, EnglishName = p1.EnglishName, Description = p1.Description, HasSpecialPage = p1.HasSpecialPage, PageUrl = p1.PageUrl, Files = funcMain1(p1.Files), Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Brand AdaptTo(this BrandLDto p3, Brand p4) { if (p3 == null) { return null; } Brand result = p4 ?? new Brand(); result.PersianName = p3.PersianName; result.EnglishName = p3.EnglishName; result.Description = p3.Description; result.HasSpecialPage = p3.HasSpecialPage; result.PageUrl = p3.PageUrl; result.Files = funcMain2(p3.Files, result.Files); result.Id = p3.Id; result.CreatedAt = p3.CreatedAt; return result; } public static Expression> ProjectToBrand => p7 => new Brand() { PersianName = p7.PersianName, EnglishName = p7.EnglishName, Description = p7.Description, HasSpecialPage = p7.HasSpecialPage, PageUrl = p7.PageUrl, Files = p7.Files.Select(p8 => new BrandStorageFile() { Name = p8.Name, FileLocation = p8.FileLocation, FileName = p8.FileName, IsHeader = p8.IsHeader, IsPrimary = p8.IsPrimary, FileType = p8.FileType, Id = p8.Id, CreatedAt = p8.CreatedAt }).ToList(), Id = p7.Id, CreatedAt = p7.CreatedAt }; public static BrandLDto AdaptToLDto(this Brand p9) { return p9 == null ? null : new BrandLDto() { PersianName = p9.PersianName, EnglishName = p9.EnglishName, Description = p9.Description, HasSpecialPage = p9.HasSpecialPage, PageUrl = p9.PageUrl, Files = funcMain3(p9.Files), Id = p9.Id, CreatedAt = p9.CreatedAt }; } public static BrandLDto AdaptTo(this Brand p11, BrandLDto p12) { if (p11 == null) { return null; } BrandLDto result = p12 ?? new BrandLDto(); result.PersianName = p11.PersianName; result.EnglishName = p11.EnglishName; result.Description = p11.Description; result.HasSpecialPage = p11.HasSpecialPage; result.PageUrl = p11.PageUrl; result.Files = funcMain4(p11.Files, result.Files); result.Id = p11.Id; result.CreatedAt = p11.CreatedAt; return result; } public static Expression> ProjectToLDto => p15 => new BrandLDto() { PersianName = p15.PersianName, EnglishName = p15.EnglishName, Description = p15.Description, HasSpecialPage = p15.HasSpecialPage, PageUrl = p15.PageUrl, Files = p15.Files.Select(p16 => new StorageFileSDto() { Name = p16.Name, FileLocation = p16.FileLocation, FileName = p16.FileName, IsHeader = p16.IsHeader, IsPrimary = p16.IsPrimary, FileType = p16.FileType, Id = p16.Id }).ToList(), Id = p15.Id, CreatedAt = p15.CreatedAt }; public static Brand AdaptToBrand(this BrandSDto p17) { return p17 == null ? null : new Brand() { PersianName = p17.PersianName, EnglishName = p17.EnglishName, Description = p17.Description, HasSpecialPage = p17.HasSpecialPage, PageUrl = p17.PageUrl, Id = p17.Id, CreatedAt = p17.CreatedAt }; } public static Brand AdaptTo(this BrandSDto p18, Brand p19) { if (p18 == null) { return null; } Brand result = p19 ?? new Brand(); result.PersianName = p18.PersianName; result.EnglishName = p18.EnglishName; result.Description = p18.Description; result.HasSpecialPage = p18.HasSpecialPage; result.PageUrl = p18.PageUrl; result.Id = p18.Id; result.CreatedAt = p18.CreatedAt; return result; } public static BrandSDto AdaptToSDto(this Brand p20) { return p20 == null ? null : new BrandSDto() { PersianName = p20.PersianName, EnglishName = p20.EnglishName, Description = p20.Description, HasSpecialPage = p20.HasSpecialPage, PageUrl = p20.PageUrl, Id = p20.Id, CreatedAt = p20.CreatedAt }; } public static BrandSDto AdaptTo(this Brand p21, BrandSDto p22) { if (p21 == null) { return null; } BrandSDto result = p22 ?? new BrandSDto(); result.PersianName = p21.PersianName; result.EnglishName = p21.EnglishName; result.Description = p21.Description; result.HasSpecialPage = p21.HasSpecialPage; result.PageUrl = p21.PageUrl; result.Id = p21.Id; result.CreatedAt = p21.CreatedAt; return result; } public static Expression> ProjectToSDto => p23 => new BrandSDto() { PersianName = p23.PersianName, EnglishName = p23.EnglishName, Description = p23.Description, HasSpecialPage = p23.HasSpecialPage, PageUrl = p23.PageUrl, Id = p23.Id, CreatedAt = p23.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) { StorageFileSDto item = p2[i]; result.Add(item == null ? null : new BrandStorageFile() { 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 funcMain2(List p5, List p6) { 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 BrandStorageFile() { 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 funcMain3(List p10) { if (p10 == null) { return null; } List result = new List(p10.Count); int i = 0; int len = p10.Count; while (i < len) { BrandStorageFile item = p10[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 funcMain4(List p13, List p14) { if (p13 == null) { return null; } List result = new List(p13.Count); int i = 0; int len = p13.Count; while (i < len) { BrandStorageFile item = p13[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; } } }