Ejemplo n.º 1
0
        public async Task <PagedResult <GetMaterialResponseModel> > SearchByName(SearchMaterialByNameQueryModel query)
        {
            var result = await _materialRepository.SearchByNameAsync(query);

            return(PagedResult <GetMaterialResponseModel>
                   .Create(result.data.Select(x => _mapper.Map <GetMaterialResponseModel>(x)).ToList(),
                           query.Page, query.Results,
                           Convert.ToInt32(Math.Ceiling((double)result.statistics.TotalResults / query.Results)),
                           result.statistics.TotalResults));
        }
Ejemplo n.º 2
0
 public async Task <(List <Domain.Material> data, QueryStatistics statistics)> SearchByNameAsync(SearchMaterialByNameQueryModel query)
 {
     return(await SessionAsync.Advanced.AsyncDocumentQuery <Domain.Material>(nameof(MaterialSearchByNameIndex))
            .WaitForNonStaleResults()
            .WhereEquals(x => x.Name, query.Name)
            .Statistics(out QueryStatistics stats)
            .Skip(query.Page * query.Results)
            .Take(query.Results)
            .OrderByDescending(query.OrderBy)
            .ToListAsync(), stats);
 }