public static async Task <Post> ToPost(this Blog.Entities.Post entity) { var post = new Post() { Id = entity.Id, Title = entity.Title, Slug = entity.Slug, CategoryId = entity.CategoryId, Content = entity.Content, UserId = entity.UserId, Created = entity.Created, Updated = entity.Updated, Likes = entity.Likes, Views = entity.Views }; post.Html = await entity.GetHtml(); post.Thumbnail = await entity.GetThumbnail(); post.Banner = await entity.GetBanner(); post.Category = await(await entity.GetCategory()).ToCategory(); post.User = await entity.GetUser(); return(post); }
public PostDisplayModel(Blog.Entities.Post post, int numberOfLetters = 200) { if (post.Content.Length > numberOfLetters) { this.Content = post.Content.Substring(0, 200); } this.Tags = post.Tags; this.Id = post.Id; this.DateCreated = post.DateCreated; this.DateUpdate = post.DateUpdate; this.Title = post.Title; this.User = post.User.UserName; this.NumberOfComments = post.Comments != null ? post.Comments.Count : -1; }