using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using HamyanEdalat.Domain.Dtos.LargDto; using HamyanEdalat.Domain.Dtos.SmallDto; using HamyanEdalat.Domain.Entities.Blogs; namespace HamyanEdalat.Domain.Mappers { public static partial class BlogMapper { public static Blog AdaptToBlog(this BlogLDto p1) { return p1 == null ? null : new Blog() { Title = p1.Title, Content = p1.Content, Tags = p1.Tags, ReadingTime = p1.ReadingTime, Summery = p1.Summery, IsSuggested = p1.IsSuggested, CategoryId = p1.CategoryId, Files = funcMain1(p1.Files), Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Blog AdaptTo(this BlogLDto p3, Blog p4) { if (p3 == null) { return null; } Blog result = p4 ?? new Blog(); result.Title = p3.Title; result.Content = p3.Content; result.Tags = p3.Tags; result.ReadingTime = p3.ReadingTime; result.Summery = p3.Summery; result.IsSuggested = p3.IsSuggested; result.CategoryId = p3.CategoryId; result.Files = funcMain2(p3.Files, result.Files); result.Id = p3.Id; result.CreatedAt = p3.CreatedAt; return result; } public static Expression> ProjectToBlog => p7 => new Blog() { Title = p7.Title, Content = p7.Content, Tags = p7.Tags, ReadingTime = p7.ReadingTime, Summery = p7.Summery, IsSuggested = p7.IsSuggested, CategoryId = p7.CategoryId, Files = p7.Files.Select(p8 => new BlogStorageFile() { 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 BlogLDto AdaptToLDto(this Blog p9) { return p9 == null ? null : new BlogLDto() { Title = p9.Title, Content = p9.Content, Tags = p9.Tags, ReadingTime = p9.ReadingTime, Summery = p9.Summery, IsSuggested = p9.IsSuggested, CategoryId = p9.CategoryId, Files = funcMain3(p9.Files), Id = p9.Id, CreatedAt = p9.CreatedAt }; } public static BlogLDto AdaptTo(this Blog p11, BlogLDto p12) { if (p11 == null) { return null; } BlogLDto result = p12 ?? new BlogLDto(); result.Title = p11.Title; result.Content = p11.Content; result.Tags = p11.Tags; result.ReadingTime = p11.ReadingTime; result.Summery = p11.Summery; result.IsSuggested = p11.IsSuggested; result.CategoryId = p11.CategoryId; result.Files = funcMain4(p11.Files, result.Files); result.Id = p11.Id; result.CreatedAt = p11.CreatedAt; return result; } public static Expression> ProjectToLDto => p15 => new BlogLDto() { Title = p15.Title, Content = p15.Content, Tags = p15.Tags, ReadingTime = p15.ReadingTime, Summery = p15.Summery, IsSuggested = p15.IsSuggested, CategoryId = p15.CategoryId, 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 Blog AdaptToBlog(this BlogSDto p17) { return p17 == null ? null : new Blog() { Title = p17.Title, Content = p17.Content, Tags = p17.Tags, ReadingTime = p17.ReadingTime, Summery = p17.Summery, IsSuggested = p17.IsSuggested, CategoryId = p17.CategoryId, Id = p17.Id, CreatedAt = p17.CreatedAt }; } public static Blog AdaptTo(this BlogSDto p18, Blog p19) { if (p18 == null) { return null; } Blog result = p19 ?? new Blog(); result.Title = p18.Title; result.Content = p18.Content; result.Tags = p18.Tags; result.ReadingTime = p18.ReadingTime; result.Summery = p18.Summery; result.IsSuggested = p18.IsSuggested; result.CategoryId = p18.CategoryId; result.Id = p18.Id; result.CreatedAt = p18.CreatedAt; return result; } public static BlogSDto AdaptToSDto(this Blog p20) { return p20 == null ? null : new BlogSDto() { Title = p20.Title, Content = p20.Content, Tags = p20.Tags, ReadingTime = p20.ReadingTime, Summery = p20.Summery, IsSuggested = p20.IsSuggested, CategoryId = p20.CategoryId, CategoryName = p20.Category == null ? null : p20.Category.Name, Id = p20.Id, CreatedAt = p20.CreatedAt }; } public static BlogSDto AdaptTo(this Blog p21, BlogSDto p22) { if (p21 == null) { return null; } BlogSDto result = p22 ?? new BlogSDto(); result.Title = p21.Title; result.Content = p21.Content; result.Tags = p21.Tags; result.ReadingTime = p21.ReadingTime; result.Summery = p21.Summery; result.IsSuggested = p21.IsSuggested; result.CategoryId = p21.CategoryId; result.CategoryName = p21.Category == null ? null : p21.Category.Name; result.Id = p21.Id; result.CreatedAt = p21.CreatedAt; return result; } public static Expression> ProjectToSDto => p23 => new BlogSDto() { Title = p23.Title, Content = p23.Content, Tags = p23.Tags, ReadingTime = p23.ReadingTime, Summery = p23.Summery, IsSuggested = p23.IsSuggested, CategoryId = p23.CategoryId, CategoryName = p23.Category.Name, 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 BlogStorageFile() { 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 BlogStorageFile() { 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) { BlogStorageFile 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) { BlogStorageFile 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; } } }