/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <returns>ActionResult.</returns> public ActionResult Edit(int id) { var model = new LabExamViewModel(); model.Groups = HealthHelper.GetAllLabExamGroups(); if (id != -1) { var svc = new LabExamAppService(); var o = svc.GetLabExam(id); model.LabExamId = o.LabExamId; model.Name = o.Name; model.LabExamGroupId = o.LabExamGroupId; } else { model.Action = "-1"; model.LabExamId = -1; model.Name = string.Empty; model.LabExamGroupId = -1; } return View(model); }
public ActionResult Edit(LabExamViewModel model) { model.Groups = HealthHelper.GetAllLabExamGroups(); try { var svc = new LabExamAppService(); var o = new LabExam { LabExamId= model.LabExamId, Name = model.Name, LabExamGroupId = model.LabExamGroupId }; if (model.Action == "-1") { var exist = svc.GetLabExam(model.LabExamId)!=null; if (!exist) { svc.AddLabExam(o); ViewBag.Feed = 0; } else { model.Action = "-1"; ViewBag.Feed = 3; return View(model); } } else { o.LabExamId= model.LabExamId; if (model.IsDeleteAction == 0) { svc.SaveLabExam(o); } else { svc.RemoveLabExam(model.LabExamId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } return View(model); }