public async Task <IEnumerable <CategoryViewModel> > GetCategoriesAsync(CategorySearchParams searchParams) { var specification = new CategoryFilterSpecification(searchParams); return(await _categoryRepository.ListAsync <CategoryViewModel>(specification, CategoryHelpers.GetCategoryMapperConfiguration())); }
public async Task <IEnumerable <Category> > GetPostCategoriesAsync(Post post) { var categoryIds = await GetCategoryIdsInPostAsync(post); var filter = new CategoryFilterSpecification(categoryIds); return(await categoryRepository.ListAsync(filter)); }
public async Task <CategoryIndexViewModel> GetCaregoryItems(int pageIndex, int itemsPage, int?typeId) { _logger.LogInformation("GetCatalogItems called."); var filterSpecification = new CategoryFilterSpecification(typeId); var root = _itemRepository.List(filterSpecification); var totalItems = root.Count(); var itemsOnPage = root .Skip(itemsPage * pageIndex) .Take(itemsPage) .ToList(); itemsOnPage.ForEach(x => { x.PictureUri = _uriComposer.ComposePicUri(x.PictureUri); }); var vm = new CategoryIndexViewModel() { CatalogItems = itemsOnPage.Select(i => new CategoryItemViewModel() { Id = i.Id, Name = i.Name, PictureUri = i.PictureUri, Price = i.Price }), Types = await GetTypes(), TypesFilterApplied = typeId ?? 0, PaginationInfo = new PaginationInfoViewModel() { ActualPage = pageIndex, ItemsPerPage = itemsOnPage.Count, TotalItems = totalItems, TotalPages = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString()) } }; vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "is-disabled" : ""; vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "is-disabled" : ""; return(vm); }
public Category GetCategoryByCode(string code) { var filter = new CategoryFilterSpecification(code); return(categoryRepository.GetSingleBySpec(filter)); }
public async Task <int> GetCategoriesCountAsync(CategorySearchParams searchParams) { var specification = new CategoryFilterSpecification(searchParams); return(await _categoryRepository.GetTotalCountAsync(specification)); }