public bool DeleteActionTakenType(ActionTakenType type) { if (type != null && type.ActionsTaken.Count == 0) { this.actionTakenTypeRepo.Delete(type); return(true); } return(false); }
public ActionResult Edit(int id) { ActionTakenType type = this.actionTakenTasks.GetActionTakenType(id); if (type != null) { return(View(new ActionTakenTypeViewModel(type))); } return(new HttpNotFoundResult()); }
public ActionResult Details(int id) { ActionTakenType att = this.actionTakenTasks.GetActionTakenType(id); if (att != null) { return(View(att)); } return(new HttpNotFoundResult()); }
public ActionTakenTypeViewModel(ActionTakenType type) { if (type != null) { this.Id = type.Id; this.ActionTakenTypeName = type.ActionTakenTypeName; this.Notes = type.Notes; this.IsRemedial = type.IsRemedial; this.IsDisciplinary = type.IsDisciplinary; } }
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 Delete(int id) { ActionTakenType type = this.actionTakenTasks.GetActionTakenType(id); if (type != null) { if (this.actionTakenTasks.DeleteActionTakenType(type)) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Details", new { id = id })); } } return(new HttpNotFoundResult()); }
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)); }
public ActionTakenType SaveActionTakenType(ActionTakenType type) { return(this.actionTakenTypeRepo.SaveOrUpdate(type)); }