public void GetAll_10_ReturnsValidSubcategories() { // Arrange const int expectedCount = SubcategoriesCount; // Act var subcategories = _subcategoryRepository.GetAll(); // Assert Assert.NotNull(subcategories); Assert.Equal(expectedCount, subcategories.Count()); }
public ActionResult Index(Query query) { ManageSearchingTermStatus(ref query.search); IEnumerable<Subcategory> model = _subcategoryRepository.GetSubcategoriesByName(query.search); if (model.Count() == 0) { model = _subcategoryRepository.GetAll(); } if (query.Reversable) { ReverseSorting(ref query.descending, query.SortOrder); } IEnumerable<SubcategoryAdminViewModel> mappedModel = _mapper.Map<IEnumerable<SubcategoryAdminViewModel>>(model); IEnumerable<SubcategoryAdminViewModel> sortedModel = mappedModel.SortBy(x => x.CategoryID, query.SortOrder, query.descending); int pageNumber = query.Page ?? 1; IPagedList<SubcategoryAdminViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 25); SaveSortingState(query.SortOrder, query.descending, query.search); return View(viewModel); }
public ActionResult Index(int?page, string sortOrder, string search, bool descending = true, bool reversable = false) { ManageSearchingTermStatus(ref search); IEnumerable <Subcategory> model = _subcategoryRepository.GetSubcategoriesByName(search); if (model.Count() == 0) { model = _subcategoryRepository.GetAll(); } if (reversable) { ReverseSorting(ref descending, sortOrder); } IEnumerable <SubcategoryAdminViewModel> mappedModel = Mapper.Map <IEnumerable <SubcategoryAdminViewModel> >(model); IEnumerable <SubcategoryAdminViewModel> sortedModel = PagedListHelper.SortBy(mappedModel, x => x.CategoryID, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <SubcategoryAdminViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 25); SaveSortingState(sortOrder, descending, search); return(View(viewModel)); }
public IEnumerable<SubcategoryViewModel> GetAll() { List<SubcategoryViewModel> subcatViewModels = new List<SubcategoryViewModel>(); foreach (Subcategory subcategory in _subcategoriesRepository.GetAll()) { SubcategoryViewModel subcategoryViewModel = MapToViewModel(subcategory); subcatViewModels.Add(subcategoryViewModel); } return subcatViewModels; }
public async Task <IEnumerable <Subcategory> > ListAsync(int?categoryId) { Expression <Func <Subcategory, bool> > predicate = null; if (categoryId.HasValue) { Guard.Against.LessOne(categoryId.Value, Resources.Category_InvalidId_ErrorMessage); if (!await _categoryRepository.ExistAsync(categoryId.Value)) { throw new RutrackerException( string.Format(Resources.Category_NotFoundById_ErrorMessage, categoryId), ExceptionEventTypes.InvalidParameters); } predicate = x => x.CategoryId == categoryId; } var subcategories = await _subcategoryRepository.GetAll(predicate).ToListAsync(); Guard.Against.NullNotFound(subcategories, string.Format(Resources.Subcategory_NotFoundByCategoryId_ErrorMessage, categoryId)); return(subcategories); }
public async Task <Pageable <Subcategory> > GetAll(int page, int size) { return(await _subcategoryRepository.GetAll(page, size)); }
public IEnumerable <SubcategorySitemapModel> GetAllSubcategories() { var subcategories = _iSubcategoryRepository.GetAll().ToList(); return(subcategories.Select(x => x.ToSitemapModel())); }