Example #1
0
        public async Task <IActionResult> Index(int page = 1)
        {
            var response = await _sanityClient.Query <Category>()
                           .OrderBy(
                p => p.UpdatedAt.Descending(),
                p => p.CreatedAt.Descending(),
                p => p.Title.Ascending()
                )
                           .GetQueryResponse();

            var tasks      = response.Result.Select(CreateCategoryViewModel);
            var viewModels = await Task.WhenAll(tasks);

            return(View(viewModels));
        }
Example #2
0
        public async Task <IActionResult> Index(Category currentDocument)
        {
            var productsResponse = await _client
                                   .Query <Product>(CultureInfo.CurrentUICulture)
                                   .Filter(p => p.MainCategory.Id.Is(currentDocument.Id))
                                   .OrFilter(p => p.Categories.MatchContained(currentDocument.Id))
                                   .GetQueryResponse();

            var model = new CategoryViewModel
            {
                Category = currentDocument,
                Products = productsResponse.Result
            };

            return(View(model));
        }
Example #3
0
 public IQueryBuilder <T> Query <T>() where T : ISanityDocument
 {
     return(_inner.Query <T>());
 }