public async Task <IActionResult> Edit(int id, [Bind("RouteStopId,BusRouteCode,BusStopNumber,OffsetMinutes")] RouteStop routeStop) { if (id != routeStop.RouteStopId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(routeStop); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RouteStopExists(routeStop.RouteStopId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["BusRouteCode"] = new SelectList(_context.BusRoute, "BusRouteCode", "BusRouteCode", routeStop.BusRouteCode); ViewData["BusStopNumber"] = new SelectList(_context.BusStop, "BusStopNumber", "BusStopNumber", routeStop.BusStopNumber); return(View(routeStop)); }
public async Task <IActionResult> Edit(string id, [Bind("BusRouteCode,RouteName")] BusRoute busRoute) { if (id != busRoute.BusRouteCode) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(busRoute); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BusRouteExists(busRoute.BusRouteCode)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(busRoute)); }
public async Task <IActionResult> Edit(int id, [Bind("BusStopNumber,GoingDowntown,Location,LocationHash")] BusStop busStop) { if (id != busStop.BusStopNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(busStop); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BusStopExists(busStop.BusStopNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(busStop)); }
public async Task <IActionResult> Edit(int id, [Bind("DriverId,City,DateHired,FirstName,FullName,HomePhone,LastName,PostalCode,ProvinceCode,Street,WorkPhone")] Driver driver) { if (id != driver.DriverId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(driver); await _context.SaveChangesAsync(); TempData["message"] = "Driver details successfully changed"; return(RedirectToAction("Index")); } catch (DbUpdateConcurrencyException ex) { if (!DriverExists(driver.DriverId)) { //return NotFound(); ModelState.AddModelError("", $"Error editing the details of driver: {ex.GetBaseException().Message}"); } else { throw; } } //TempData["successMessage"] = "Successfully changed details"; } ViewData["ProvinceCode"] = new SelectList(_context.Province, "ProvinceCode", "ProvinceCode", driver.ProvinceCode); return(View(driver)); }
public async Task <IActionResult> Edit(int id, [Bind("RouteScheduleId,BusRouteCode,Comments,IsWeekDay,StartTime")] RouteSchedule routeSchedule) { if (id != routeSchedule.RouteScheduleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(routeSchedule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RouteScheduleExists(routeSchedule.RouteScheduleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["BusRouteCode"] = new SelectList(_context.BusRoute, "BusRouteCode", "BusRouteCode", routeSchedule.BusRouteCode); return(View(routeSchedule)); }
public async Task <IActionResult> Edit(string id, [Bind("ProvinceCode,Capital,CountryCode,Name,TaxCode,TaxRate")] Province province) { if (id != province.ProvinceCode) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(province); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProvinceExists(province.ProvinceCode)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["CountryCode"] = new SelectList(_context.Country, "CountryCode", "CountryCode", province.CountryCode); return(View(province)); }
public async Task <IActionResult> Edit(string id, [Bind("CountryCode,Name,PhonePattern,PostalPattern")] Country country) { if (id != country.CountryCode) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(country); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(country.CountryCode)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(country)); }
public async Task <IActionResult> Edit(int id, [Bind("DriverId,City,DateHired,FirstName,FullName,HomePhone,LastName,PostalCode,ProvinceCode,Street,WorkPhone")] Driver driver) { if (id != driver.DriverId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(driver); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DriverExists(driver.DriverId)) { return(NotFound()); } else { throw; } } ViewData["message"] = "Successfully editied driver"; return(RedirectToAction("Index")); } ViewData["ProvinceCode"] = new SelectList(_context.Province.OrderBy(p => p.ProvinceCode), "ProvinceCode", "ProvinceCode"); return(View(driver)); }
public async Task <IActionResult> Edit(int id, [Bind("DriverId,City,DateHired,FirstName,FullName,HomePhone,LastName,PostalCode,ProvinceCode,Street,WorkPhone")] Driver driver) { try { if (id != driver.DriverId) { return(NotFound()); } if (ModelState.IsValid) { try { driver.FullName = driver.LastName + ", " + driver.FirstName; driver.HomePhone = driver.HomePhone.Substring(0, 3) + "-" + driver.HomePhone.Substring(3, 3) + "-" + driver.HomePhone.Substring(6); if (!String.IsNullOrEmpty(driver.WorkPhone)) { driver.WorkPhone = driver.WorkPhone.Substring(0, 3) + "-" + driver.WorkPhone.Substring(3, 3) + "-" + driver.WorkPhone.Substring(6); } _context.Update(driver); TempData["message"] = driver.FullName + "Record Updated Successfully !!"; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DriverExists(driver.DriverId)) { return(NotFound()); } else { throw; } } catch (Exception ex) { ModelState.AddModelError("", $"error {ex.GetBaseException().Message}"); } return(RedirectToAction("Index")); } ViewData["ProvinceCode"] = new SelectList(_context.Province, "ProvinceCode", "ProvinceCode", driver.ProvinceCode); return(View(driver)); } catch (Exception ex) { ModelState.AddModelError("", "Error ! Cannot Edit the driver" + ex.GetBaseException().Message); return(RedirectToAction(actionName: "Edit", controllerName: "MKDriver")); } }