public async Task <List <AuthorEntity> > GetAuthors() { if (_cacheProvider.TryGet(CacheConstants.SquidexSchemas.Authors, out List <AuthorEntity> items)) { return(items); } items = await _squidexRepo.GetAuthors(); _cacheProvider.Set(CacheConstants.SquidexSchemas.Authors, 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)); }