コード例 #1
0
 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());
 }
コード例 #2
0
        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));
        }