using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Mapster.Models; using Netina.Domain.Dtos.LargDtos; using Netina.Domain.Dtos.SmallDtos; using Netina.Domain.Entities.Blogs; using Netina.Domain.Entities.Users; namespace Netina.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, Slug = p1.Slug, Tags = p1.Tags, ReadingTime = p1.ReadingTime, Summery = p1.Summery, IsSuggested = p1.IsSuggested, CategoryId = p1.CategoryId, Category = new BlogCategory() { Name = p1.CategoryName, Id = p1.CategoryId }, Files = funcMain1(p1.Files), MetaTags = funcMain2(p1.MetaTags), AuthorId = p1.AuthorId, Author = new ApplicationUser() {Id = p1.AuthorId}, Id = p1.Id, CreatedAt = p1.CreatedAt }; } public static Blog AdaptTo(this BlogLDto p4, Blog p5) { if (p4 == null) { return null; } Blog result = p5 ?? new Blog(); result.Title = p4.Title; result.Content = p4.Content; result.Slug = p4.Slug; result.Tags = p4.Tags; result.ReadingTime = p4.ReadingTime; result.Summery = p4.Summery; result.IsSuggested = p4.IsSuggested; result.CategoryId = p4.CategoryId; result.Category = funcMain3(new Never(), result.Category, p4); result.Files = funcMain4(p4.Files, result.Files); result.MetaTags = funcMain5(p4.MetaTags, result.MetaTags); result.AuthorId = p4.AuthorId; result.Author = funcMain6(new Never(), result.Author, p4); result.Id = p4.Id; result.CreatedAt = p4.CreatedAt; return result; } public static Expression> ProjectToBlog => p14 => new Blog() { Title = p14.Title, Content = p14.Content, Slug = p14.Slug, Tags = p14.Tags, ReadingTime = p14.ReadingTime, Summery = p14.Summery, IsSuggested = p14.IsSuggested, CategoryId = p14.CategoryId, Category = new BlogCategory() { Name = p14.CategoryName, Id = p14.CategoryId }, Files = p14.Files.Select(p15 => new BlogStorageFile() { Name = p15.Name, FileLocation = p15.FileLocation, FileName = p15.FileName, IsHeader = p15.IsHeader, IsPrimary = p15.IsPrimary, FileType = p15.FileType, Id = p15.Id, CreatedAt = p15.CreatedAt }).ToList(), MetaTags = p14.MetaTags.Select(p16 => new BlogMetaTag() { Type = p16.Type, Value = p16.Value, Id = p16.Id, CreatedAt = p16.CreatedAt }).ToList(), AuthorId = p14.AuthorId, Author = new ApplicationUser() {Id = p14.AuthorId}, Id = p14.Id, CreatedAt = p14.CreatedAt }; public static BlogLDto AdaptToLDto(this Blog p17) { return p17 == null ? null : new BlogLDto() { Title = p17.Title, Content = p17.Content, Tags = p17.Tags, Slug = p17.Slug, ReadingTime = p17.ReadingTime, Summery = p17.Summery, MainImage = p17.Files.Count > 0 && p17.Files.Any(funcMain7) ? p17.Files.FirstOrDefault(funcMain8).FileName : string.Empty, IsSuggested = p17.IsSuggested, CategoryId = p17.CategoryId, CategoryName = p17.Category == null ? null : p17.Category.Name, AuthorId = p17.AuthorId, AuthorFullName = p17.Author != null ? p17.Author.FirstName + " " + p17.Author.LastName : string.Empty, MetaTags = funcMain9(p17.MetaTags), Files = funcMain10(p17.Files), Id = p17.Id, CreatedAt = p17.CreatedAt }; } public static BlogLDto AdaptTo(this Blog p20, BlogLDto p21) { if (p20 == null) { return null; } BlogLDto result = p21 ?? new BlogLDto(); result.Title = p20.Title; result.Content = p20.Content; result.Tags = p20.Tags; result.Slug = p20.Slug; result.ReadingTime = p20.ReadingTime; result.Summery = p20.Summery; result.MainImage = p20.Files.Count > 0 && p20.Files.Any(funcMain7) ? p20.Files.FirstOrDefault(funcMain8).FileName : string.Empty; result.IsSuggested = p20.IsSuggested; result.CategoryId = p20.CategoryId; result.CategoryName = p20.Category == null ? null : p20.Category.Name; result.AuthorId = p20.AuthorId; result.AuthorFullName = p20.Author != null ? p20.Author.FirstName + " " + p20.Author.LastName : string.Empty; result.MetaTags = funcMain11(p20.MetaTags, result.MetaTags); result.Files = funcMain12(p20.Files, result.Files); result.Id = p20.Id; result.CreatedAt = p20.CreatedAt; return result; } public static Expression> ProjectToLDto => p26 => new BlogLDto() { Title = p26.Title, Content = p26.Content, Tags = p26.Tags, Slug = p26.Slug, ReadingTime = p26.ReadingTime, Summery = p26.Summery, MainImage = p26.Files.Count > 0 && p26.Files.Any(f => f.IsPrimary) ? p26.Files.FirstOrDefault(f => f.IsPrimary).FileName : string.Empty, IsSuggested = p26.IsSuggested, CategoryId = p26.CategoryId, CategoryName = p26.Category.Name, AuthorId = p26.AuthorId, AuthorFullName = p26.Author != null ? p26.Author.FirstName + " " + p26.Author.LastName : string.Empty, MetaTags = p26.MetaTags.Select(p27 => new MetaTagSDto() { Type = p27.Type, Value = p27.Value, Id = p27.Id, CreatedAt = p27.CreatedAt }).ToList(), Files = p26.Files.Select(p28 => new StorageFileSDto() { Name = p28.Name, FileLocation = p28.FileLocation, FileName = p28.FileName, IsHeader = p28.IsHeader, IsPrimary = p28.IsPrimary, FileType = p28.FileType, Id = p28.Id }).ToList(), Id = p26.Id, CreatedAt = p26.CreatedAt }; public static Blog AdaptToBlog(this BlogSDto p29) { return p29 == null ? null : new Blog() { Title = p29.Title, Slug = p29.Slug, Tags = p29.Tags, ReadingTime = p29.ReadingTime, Summery = p29.Summery, IsSuggested = p29.IsSuggested, CategoryId = p29.CategoryId, Category = new BlogCategory() { Name = p29.CategoryName, Id = p29.CategoryId }, AuthorId = p29.AuthorId, Author = new ApplicationUser() {Id = p29.AuthorId}, Id = p29.Id, CreatedAt = p29.CreatedAt, ModifiedAt = p29.ModifiedAt }; } public static Blog AdaptTo(this BlogSDto p30, Blog p31) { if (p30 == null) { return null; } Blog result = p31 ?? new Blog(); result.Title = p30.Title; result.Slug = p30.Slug; result.Tags = p30.Tags; result.ReadingTime = p30.ReadingTime; result.Summery = p30.Summery; result.IsSuggested = p30.IsSuggested; result.CategoryId = p30.CategoryId; result.Category = funcMain13(new Never(), result.Category, p30); result.AuthorId = p30.AuthorId; result.Author = funcMain14(new Never(), result.Author, p30); result.Id = p30.Id; result.CreatedAt = p30.CreatedAt; result.ModifiedAt = p30.ModifiedAt; return result; } public static BlogSDto AdaptToSDto(this Blog p36) { return p36 == null ? null : new BlogSDto() { Title = p36.Title, Slug = p36.Slug, Tags = p36.Tags, ReadingTime = p36.ReadingTime, Summery = p36.Summery, IsSuggested = p36.IsSuggested, CategoryId = p36.CategoryId, CategoryName = p36.Category == null ? null : p36.Category.Name, MainImage = p36.Files.Count > 0 && p36.Files.Any(funcMain15) ? p36.Files.FirstOrDefault(funcMain16).FileName : string.Empty, ModifiedAt = p36.ModifiedAt, AuthorId = p36.AuthorId, Id = p36.Id, CreatedAt = p36.CreatedAt }; } public static BlogSDto AdaptTo(this Blog p37, BlogSDto p38) { if (p37 == null) { return null; } BlogSDto result = p38 ?? new BlogSDto(); result.Title = p37.Title; result.Slug = p37.Slug; result.Tags = p37.Tags; result.ReadingTime = p37.ReadingTime; result.Summery = p37.Summery; result.IsSuggested = p37.IsSuggested; result.CategoryId = p37.CategoryId; result.CategoryName = p37.Category == null ? null : p37.Category.Name; result.MainImage = p37.Files.Count > 0 && p37.Files.Any(funcMain15) ? p37.Files.FirstOrDefault(funcMain16).FileName : string.Empty; result.ModifiedAt = p37.ModifiedAt; result.AuthorId = p37.AuthorId; result.Id = p37.Id; result.CreatedAt = p37.CreatedAt; return result; } public static Expression> ProjectToSDto => p39 => new BlogSDto() { Title = p39.Title, Slug = p39.Slug, Tags = p39.Tags, ReadingTime = p39.ReadingTime, Summery = p39.Summery, IsSuggested = p39.IsSuggested, CategoryId = p39.CategoryId, CategoryName = p39.Category.Name, MainImage = p39.Files.Count > 0 && p39.Files.Any(f => f.IsPrimary) ? p39.Files.FirstOrDefault(f => f.IsPrimary).FileName : string.Empty, ModifiedAt = p39.ModifiedAt, AuthorId = p39.AuthorId, Id = p39.Id, CreatedAt = p39.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 p3) { if (p3 == null) { return null; } List result = new List(p3.Count); int i = 0; int len = p3.Count; while (i < len) { MetaTagSDto item = p3[i]; result.Add(item == null ? null : new BlogMetaTag() { Type = item.Type, Value = item.Value, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static BlogCategory funcMain3(Never p6, BlogCategory p7, BlogLDto p4) { BlogCategory result = p7 ?? new BlogCategory(); result.Name = p4.CategoryName; result.Id = p4.CategoryId; return result; } private static List funcMain4(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) { StorageFileSDto item = p8[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 funcMain5(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) { MetaTagSDto item = p10[i]; result.Add(item == null ? null : new BlogMetaTag() { Type = item.Type, Value = item.Value, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static ApplicationUser funcMain6(Never p12, ApplicationUser p13, BlogLDto p4) { ApplicationUser result = p13 ?? new ApplicationUser(); result.Id = p4.AuthorId; return result; } private static bool funcMain7(BlogStorageFile f) { return f.IsPrimary; } private static bool funcMain8(BlogStorageFile f) { return f.IsPrimary; } private static List funcMain9(List p18) { if (p18 == null) { return null; } List result = new List(p18.Count); int i = 0; int len = p18.Count; while (i < len) { BlogMetaTag item = p18[i]; result.Add(item == null ? null : new MetaTagSDto() { Type = item.Type, Value = item.Value, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain10(List p19) { if (p19 == null) { return null; } List result = new List(p19.Count); int i = 0; int len = p19.Count; while (i < len) { BlogStorageFile item = p19[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 funcMain11(List p22, List p23) { if (p22 == null) { return null; } List result = new List(p22.Count); int i = 0; int len = p22.Count; while (i < len) { BlogMetaTag item = p22[i]; result.Add(item == null ? null : new MetaTagSDto() { Type = item.Type, Value = item.Value, Id = item.Id, CreatedAt = item.CreatedAt }); i++; } return result; } private static List funcMain12(List p24, List p25) { if (p24 == null) { return null; } List result = new List(p24.Count); int i = 0; int len = p24.Count; while (i < len) { BlogStorageFile item = p24[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 BlogCategory funcMain13(Never p32, BlogCategory p33, BlogSDto p30) { BlogCategory result = p33 ?? new BlogCategory(); result.Name = p30.CategoryName; result.Id = p30.CategoryId; return result; } private static ApplicationUser funcMain14(Never p34, ApplicationUser p35, BlogSDto p30) { ApplicationUser result = p35 ?? new ApplicationUser(); result.Id = p30.AuthorId; return result; } private static bool funcMain15(BlogStorageFile f) { return f.IsPrimary; } private static bool funcMain16(BlogStorageFile f) { return f.IsPrimary; } } }