public IActionResult ChangePage(AddedCategoriesViewModel model, int id) { this.StartUp(); var returnModel = this.addedCategoriesService.ChangeActivePage(model, id); return(this.View(returnModel)); }
public IActionResult EditCategory(AddedCategoriesViewModel model, string id) { this.StartUp(); var returnModel = this.addedCategoriesService.GetCategoryData(id); this.TempData["editCategoryId"] = id; return(this.View("EditCategory", returnModel)); }
public IActionResult DeleteCategory(AddedCategoriesViewModel model, string id) { this.StartUp(); var returnModel = this.addedCategoriesService.DeleteCategory(this.userId, model, id); this.ViewData["message"] = "Успешно премахнат жанр!"; return(this.View("Index", returnModel)); }
public AddedCategoriesViewModel DeleteCategory(string userId, AddedCategoriesViewModel model, string categoryId) { var category = this.context.Categories.FirstOrDefault(c => c.Id == categoryId); category.DeletedOn = DateTime.UtcNow; this.context.SaveChanges(); return(this.PreparedPage()); }
public AddedCategoriesViewModel GetAllAddedCategories(AddedCategoriesViewModel model) { var genreName = model.SearchCategory.Name; var sortMethodId = model.SortMethodId; var countBooksOfPage = model.CountCategoriesOfPage; var currentPage = model.CurrentPage; var categories = this.context.Categories .Where(c => c.DeletedOn == null) .OrderBy(c => c.Name) .Select(c => new CategoryViewModel() { Id = c.Id, Name = c.Name, ParentId = c.ParentCategoryId, ParentName = c.ParentCategory.Name, }); categories = this.SelectGenres(genreName, categories); categories = this.SortGenres(sortMethodId, categories); int maxCountPage = categories.Count() / countBooksOfPage; if (categories.Count() % countBooksOfPage != 0) { maxCountPage++; } var viewCategories = categories.Skip((currentPage - 1) * countBooksOfPage) .Take(countBooksOfPage) .ToList(); var returnModel = new AddedCategoriesViewModel() { Categories = viewCategories, CountCategoriesOfPage = model.CountCategoriesOfPage, CountCategoriesOfPageList = model.CountCategoriesOfPageList, SortMethodId = model.SortMethodId, SearchCategory = model.SearchCategory, }; return(returnModel); }
public AddedCategoriesViewModel ChangeActivePage(AddedCategoriesViewModel model, int id) { model.CurrentPage = id; return(this.GetAllAddedCategories(model)); }
public AddedCategoriesViewModel PreparedPage() { var model = new AddedCategoriesViewModel(); return(this.GetAllAddedCategories(model)); }