public ActionResult Edit(BodyPartViewModel model) { try { var svc = new BodyPartAppService(); var o = new BodyPart { BodyPartId= model.BodyPartId, Name = model.Name, }; if (model.Action == "-1") { var exist = svc.GetBodyPart(model.BodyPartId)!=null; if (!exist) { svc.AddBodyPart(o); ViewBag.Feed = 0; } else { model.Action = "-1"; ViewBag.Feed = 3; return View(model); } } else { o.BodyPartId= model.BodyPartId; if (model.IsDeleteAction == 0) { svc.SaveBodyPart(o); } else { svc.RemoveBodyPart(model.BodyPartId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } return View(model); }