// GET: Drivers/Edit/5 public ActionResult Edit(int id) { sqlconn.Open(); UserDriver driver = UserDriverLogic.FindById(sqlconn, id); sqlconn.Close(); return(View(driver)); }
// GET: Drivers public ActionResult Index() { sqlconn.Open(); List <UserDriver> drivers = UserDriverLogic.FindAll(sqlconn); sqlconn.Close(); return(View(drivers)); }
// GET: Vehicles/Create public ActionResult Create() { sqlconn.Open(); List <VehicleType> types = VehicleTypeXmlMapper.SelectAll(); List <VehicleBrand> brands = VehicleBrandXmlMapper.SelectAll(); List <UserDriver> drivers = UserDriverLogic.FindAll(sqlconn); List <UserBoss> bosses = UserBossLogic.FindAll(sqlconn); sqlconn.Close(); ViewData["vehicleTypes"] = types; ViewData["vehicleBrands"] = brands; ViewData["drivers"] = drivers; ViewData["bosses"] = bosses; return(View()); }
public ActionResult Edit(int id, UserDriver driver) { try { sqlconn.Open(); int result = UserDriverLogic.Update(sqlconn, driver); sqlconn.Close(); if (result != 0) { throw new Exception(); } return(RedirectToAction(nameof(Index))); } catch { return(View(driver)); } }