public async Task <BlogPost> GetBlogPost(string id) { var posts = await GetItemFromCache(CacheConstants.BlogPosts, () => _repo.GetBlogPosts()); var post = posts.FirstOrDefault(p => p.Id == id); var skills = await GetItemFromCache(CacheConstants.SkillTypes, () => _repo.GetSkillTypes(pageSize: 1000)); var postSkills = skills.Where(s => post.Data.Skills.Contains(s.Id)).ToList(); return(_mapper.MapToBlogPost(post, postSkills)); }
public async Task <BlogPost> GetBlogPost(string id) { var posts = await GetItemFromCache(CacheConstants.SquidexSchemas.BlogPosts, () => _repo.GetBlogPosts()); var post = posts.FirstOrDefault(p => p.Id == id); var authors = await GetItemFromCache(CacheConstants.SquidexSchemas.Authors, () => _repo.GetAuthors()); var author = authors.FirstOrDefault(a => a.Id == post.Data.Author.First()); return(_mapper.MapToBlogPost(post, author)); }
public async Task <BlogPost> GetBlogPost(string slug) { var posts = await _cache.GetBlogPosts(); var post = posts.FirstOrDefault(p => p.Data.Slug == slug); var authors = await _cache.GetAuthors(); var author = authors.FirstOrDefault(a => a.Id == post.Data.Author.First()); return(_mapper.MapToBlogPost(post, author)); }
public async Task <BlogPost> GetBlogPost(string id) { var posts = await _repo.GetBlogPosts(); var post = posts.FirstOrDefault(p => p.Id == id); var categories = await _repo.GetBlogCategories(); var category = categories.Where(c => post.Data.Categories.Contains(c.Id)).FirstOrDefault(); var tags = await _repo.GetBlogPostTags(); tags = tags.Where(t => post.Data.Tags.Contains(t.Id)).ToList(); return(_mapper.MapToBlogPost(post, category, tags)); }