public ActionResult Edit([Bind(Include = "routeStopId,busRouteCode,busStopNumber,offsetMinutes")] routeStop routeStop) { if (ModelState.IsValid) { //Examines cookie or session variables to assign to routeStop.busRouteCode if (Request.Cookies["busRoutecode"] != null) { routeStop.busRouteCode = Request.Cookies["busRouteCode"].Value; } else if (Session["busRouteCode"] != null) { routeStop.busRouteCode = Session["busRouteCode"].ToString(); } else { TempData["message"] = "Please select Bus Route.."; return(RedirectToAction("index", "SPBusRoute")); } db.Entry(routeStop).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.busRouteCode = new SelectList(db.busRoutes, "busRouteCode", "routeName", routeStop.busRouteCode); ViewBag.busStopNumber = new SelectList(db.busStops, "busStopNumber", "location", routeStop.busStopNumber); return(View(routeStop)); }
public ActionResult Edit([Bind(Include = "busRouteCode,routeName")] busRoute busRoute) { if (ModelState.IsValid) { db.Entry(busRoute).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(busRoute)); }
public ActionResult Edit([Bind(Include = "routeScheduleId,busRouteCode,startTime,isWeekDay,comments")] routeSchedule routeSchedule) { if (ModelState.IsValid) { db.Entry(routeSchedule).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.busRouteCode = new SelectList(db.busRoutes, "busRouteCode", "routeName", routeSchedule.busRouteCode); return(View(routeSchedule)); }
public ActionResult Edit([Bind(Include = "busStopNumber,location,locationHash,goingDowntown")] busStop busStop) { if (ModelState.IsValid) { // Calculating byte sum of a String and it's going to be a locationHash int byteSum = 0; for (int i = 0; i < busStop.location.Length; i++) { byteSum += (byte)busStop.location[i]; } busStop.locationHash = byteSum; db.Entry(busStop).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(busStop)); }