async Task <PostItem> PostToItem(Post p, bool sanitize = false) { var post = new PostItem { Id = p.Id, PostType = p.PostType, Slug = p.Slug, Title = p.Title, Description = p.Description, Content = p.Content, Categories = await _categoryProvider.GetPostCategories(p.Id), Cover = p.Cover, PostViews = p.PostViews, Rating = p.Rating, Published = p.Published, Featured = p.IsFeatured, Author = _db.Authors.Single(a => a.Id == p.AuthorId), SocialFields = new List <SocialField>() }; if (post.Author != null) { if (string.IsNullOrEmpty(post.Author.Avatar)) { string.Format(Constants.AvatarDataImage, post.Author.DisplayName.Substring(0, 1).ToUpper()); } post.Author.Email = sanitize ? "*****@*****.**" : post.Author.Email; } return(await Task.FromResult(post)); }
public async Task <ICollection <Category> > GetPostCategories(int postId) { return(await _categoryProvider.GetPostCategories(postId)); }