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 _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)); }
public async Task <List <BlogPostEntity> > GetBlogPosts(int page = 0, int pageSize = 999) { if (_cacheProvider.TryGet(CacheConstants.SquidexSchemas.BlogPosts, out List <BlogPostEntity> items)) { return(items); } items = await _squidexRepo.GetBlogPosts(page, pageSize); _cacheProvider.Set(CacheConstants.SquidexSchemas.BlogPosts, items); return(items); }
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)); }