public ActionResult MountValve(int aSystemID, System.Nullable<int> valveID, string returnURL) { ModelState.Clear(); if (valveID==null) { ModelState.AddModelError("valveIDErr", "Не выбран КЗР"); } else { try { ASystem system = repositorie.Asystems.SingleOrDefault(aS => aS.AS_ID == aSystemID); system.AS_Valve = valveID; repositorie.SaveASystem(system); } catch (Exception e) { ModelState.AddModelError("0", e.Message); } } if(ModelState.IsValid) { return Redirect(returnURL); } else { MountValve_VM model = new MountValve_VM { System = repositorie.Asystems.SingleOrDefault(aS => aS.AS_ID == aSystemID), ReservedValves = repositorie.GetReservedValves(uRepositorie.Users.SingleOrDefault(u => u.Name == System.Web.HttpContext.Current.User.Identity.Name).Enterprise), ReturnURL = returnURL }; return View(model); } }
public ActionResult MountValve(int aSystemID,string returnURL) { MountValve_VM model = new MountValve_VM { System = repositorie.Asystems.SingleOrDefault(aS=>aS.AS_ID==aSystemID), ReservedValves = repositorie.GetReservedValves(uRepositorie.Users.SingleOrDefault(u=>u.Name==System.Web.HttpContext.Current.User.Identity.Name).Enterprise), ReturnURL = returnURL }; return View(model); }