/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <returns>ActionResult.</returns> public ActionResult Edit(int id) { var model = new LabExamGroupViewModel(); if (id != -1) { var svc = new LabExamGroupAppService(); var o = svc.GetLabExamGroup(id); model.LabExamGroupId = o.LabExamGroupId; model.Name = o.Name; } else { model.Action = "-1"; model.LabExamGroupId = -1; model.Name = string.Empty; } return View(model); }
public ActionResult Edit(LabExamGroupViewModel model) { try { var svc = new LabExamGroupAppService(); var o = new LabExamGroup { LabExamGroupId= model.LabExamGroupId, Name = model.Name, }; if (model.Action == "-1") { var exist = svc.GetLabExamGroup(model.LabExamGroupId)!=null; if (!exist) { svc.AddLabExamGroup(o); ViewBag.Feed = 0; } else { model.Action = "-1"; ViewBag.Feed = 3; return View(model); } } else { o.LabExamGroupId= model.LabExamGroupId; if (model.IsDeleteAction == 0) { svc.SaveLabExamGroup(o); } else { svc.RemoveLabExamGroup(model.LabExamGroupId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } return View(model); }