public ActionResult AddBus(AddBusViewModel model) { int cityId = (int)Session["City"]; if(ModelState.IsValid) { try { busRepository.Insert(new Bus { Number = model.Number, CityId = cityId }); TempData["Success"] = "Запись добавлена"; model = new AddBusViewModel(); } catch(Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex); ModelState.AddModelError("", "Ошибка при добавлении записи. Повторите попытку позже"); } } return View(model); }
public ActionResult AddBus() { AddBusViewModel model = new AddBusViewModel(); return View(model); }