// GET: Administration/Categories public async Task <IActionResult> Index(int page = 1) { IndexCategoriesViewModel model = new IndexCategoriesViewModel(); model.Categories = await this.categoriesService.GetAllForPagination <CategoryViewModel>(page, model.ItemsPerPage); model.ElementsCount = this.categories.AllWithDeleted().Count(); model.PageNumber = page; return(this.View(model)); }
public IActionResult Deleted(int page = 1) { var skip = this.pagingService.CountSkip(page, GlobalConstants.AdministrationItemsPerPage); var result = this.categoriesService.GetAllDeletedCategories <IndexCategoryViewModel>(GlobalConstants.AdministrationItemsPerPage, skip); var categoriesCount = this.categoriesService.GetCountOfDeletedCategories(); var model = new IndexCategoriesViewModel() { Categories = result, PagesCount = this.pagingService.PagesCount(categoriesCount, GlobalConstants.AdministrationItemsPerPage), }; model.CurrentPage = this.pagingService.SetPage(page, model.PagesCount); return(this.View(model)); }
public IActionResult Index() { var model = new List <IndexCategoriesViewModel>(); var categories = categoryService.GetAll(); foreach (var item in categories) { var category = new IndexCategoriesViewModel { Description = item.Description, ImageUrl = item.ImageUrl, Name = item.Name, Title = item.Title, PostSCount = item.Posts.Count() }; model.Add(category); } return(this.View(model)); }