public ActionResult Edit(int id, [Bind("CategoryId,Name")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _categoriesRepository.EditCategory(category); } catch (DbUpdateConcurrencyException) { if (!_categoriesRepository.CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } ViewBag.SelectedNav = "Dashboard"; return(RedirectToAction(nameof(Index))); } ViewBag.SelectedNav = "Dashboard"; return(View(category)); }