public ActionResult Add(Writer writer) { ValidationResult results = writerValidator.Validate(writer); if (results.IsValid) { writerManager.Add(writer); return(RedirectToAction("Index")); } else { foreach (var item in results.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
public ActionResult Add(Writer writer) { ValidationResult result = writerValidator.Validate(writer); if (result.IsValid) { writerManager.Add(writer); return(RedirectToAction("List")); } else { foreach (var error in result.Errors) { ModelState.AddModelError(error.PropertyName, error.ErrorMessage); } return(View(writer)); } }