Exemplo n.º 1
0
        public async Task <IEnumerable <ProductModel> > GetAll(PaginationModel paginationModel)
        {
            var search = await context.SearchAsync <ProductModel>(x => x
                                                                  .From(paginationModel.Offset)
                                                                  .Size(paginationModel.PageSize)
                                                                  .Query(q => q.MatchAll())
                                                                  .Index(context.GetIndexName <ProductModel>()));

            return(search.Documents);
        }
        public async Task <IEnumerable <ProductModel> > GetAll(int userId, PaginationModel paginationModel)
        {
            var search = await context.SearchAsync <WishModel>(x => x
                                                               .Query(q => q.Term(f => f.Field("_id").Value(userId)))
                                                               .Index(context.GetIndexName <WishModel>()));

            return(search.Documents.Any() ?
                   search.Documents.First().Products
                   .Skip(paginationModel.Offset)
                   .Take(paginationModel.PageSize)
                   .OrderBy(x => x.Id) :
                   Enumerable.Empty <ProductModel>());
        }