public ActionResult Edit(SpecialtyViewModel model) { try { var svc = new SpecialtyAppService(); var o = new Specialty { SpecialtyId= model.SpecialtyId, Name = model.Name, }; if (model.Action == "-1") { var exist = svc.GetSpecialty(model.SpecialtyId)!=null; if (!exist) { svc.AddSpecialty(o); ViewBag.Feed = 0; } else { model.Action = "-1"; ViewBag.Feed = 3; return View(model); } } else { o.SpecialtyId= model.SpecialtyId; if (model.IsDeleteAction == 0) { svc.SaveSpecialty(o); } else { svc.RemoveSpecialty(model.SpecialtyId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } return View(model); }