Esempio n. 1
0
 public async Task <int> GetCategoriesCountAsync()
 {
     try
     {
         return(await _categoriesRepository.CountAsync());
     }
     catch (Exception ex)
     {
         _logger?.LogError(ex.ToString());
         throw;
     }
 }
Esempio n. 2
0
        public async Task <PaginatedList <CategoryModel> > Get(SearchModel model)
        {
            var spec = model.ToSpecification <Category>();

            var entities = await _repository.Get(spec);

            var count = await _repository.CountAsync();

            return(new PaginatedList <CategoryModel>(
                       model.PageIndex,
                       entities.Count,
                       count,
                       _mapper.Map <IList <CategoryModel> >(entities)));
        }
Esempio n. 3
0
        public async Task <IActionResult> Index(int page = 1, string search = null)
        {
            var skip       = (page - 1) * SizePage;
            var categories = await categoriesRepository.GetCategoriesAsync(skip, SizePage, search);

            var totalCount = await categoriesRepository.CountAsync(search);

            return(View(new Pagination <ProductCategory>
            {
                Records = categories,
                Page = page,
                PerPage = SizePage,
                CountRecords = totalCount,
                Search = search
            }));
        }