public ActionResult Edit(Category category)
{
if (ModelStateAndCategoryNameIsValid(category))
{
if (CategoryAlreadyExists(category))
{
this.Error("A category with that name already exists.");
//ModelState.AddModelError("", "A category with that name already exists.");
return View(category);
}
else
{
repository.SaveCategory(category);
this.Success("The category has been saved");
return RedirectToAction("Index");
}
}
return View(category);
}