public ActionResult Create(ActionTakenTypeViewModel vm) { if (ModelState.IsValid) { ActionTakenType type = new ActionTakenType(); type.ActionTakenTypeName = vm.ActionTakenTypeName; type.Notes = vm.Notes; type.IsRemedial = vm.IsRemedial; type.IsDisciplinary = vm.IsDisciplinary; type = this.actionTakenTasks.SaveActionTakenType(type); return(RedirectToAction("Details", new { id = type.Id })); } return(Create()); }
public ActionResult Edit(ActionTakenTypeViewModel vm) { ActionTakenType type = this.actionTakenTasks.GetActionTakenType(vm.Id); IList <ActionTakenType> types = this.actionTakenTasks.GetActionTakenTypesByName(vm.ActionTakenTypeName); if (type != null && types != null && types.Any() && types.Where(x => x.Id != type.Id).Any()) { ModelState.AddModelError("ActionTakenTypeName", "Action taken type already exists."); } if (ModelState.IsValid) { type.ActionTakenTypeName = vm.ActionTakenTypeName; type.Notes = vm.Notes; type.IsRemedial = vm.IsRemedial; type.IsDisciplinary = vm.IsDisciplinary; type = this.actionTakenTasks.SaveActionTakenType(type); return(RedirectToAction("Details", new { id = vm.Id })); } return(Edit(vm.Id)); }