public ActionResult Add(WorkshopEditModel model) { if (!ModelState.IsValid) { // Pass the action to the form so it knows to return to Add ViewData["Action"] = "Add"; // Add list of projects and employees to choose from LoadListsForEdit(model); return(View(model)); } // Provider code must be unique. Validate if (!_workshopService.SessionIdentifierIsUnique(model.SessionIdentifier)) { ModelState.AddModelError("", "Session Identifier already used. " + " Please enter a unique session identifier."); // Pass the action to the form so it knows to return to Add ViewData["Action"] = "Add"; // Add list of projects and employees to choose from LoadListsForEdit(model); return(View(model)); } // Add workshop to db model = _workshopService.AddOrUpdate(model); return(RedirectToAction(nameof(Details), new { id = model.Id })); }