public ActionResult EditRoute(RouteModel model) { if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON)) { return(new HttpStatusCodeResult(403)); } if (ModelState.IsValid) { BL.Route r = MainClass.Instance.getRoutes().Find(v => v.id == model.id); if (r != null) { r.driveTimeMinutes = model.driveTimeMinutes; r.startPoint.name = model.startPointName; r.startPoint.latitude = (decimal)System.Web.HttpContext.Current.Session["startPointLatitude"]; r.startPoint.longitude = (decimal)System.Web.HttpContext.Current.Session["startPointLongitude"]; r.startPoint.saveInDB(); r.endPoint.name = model.endPointName; r.endPoint.latitude = (decimal)System.Web.HttpContext.Current.Session["endPointLatitude"]; r.endPoint.longitude = (decimal)System.Web.HttpContext.Current.Session["endPointLongitude"]; r.endPoint.saveInDB(); if (r.saveInDB() != null) { return(RedirectToAction("ViewRoute", "Trip")); } } } ViewBag.Status = false; ViewBag.Message = "Could not edit route"; return(View()); }
public ActionResult EditRoute(int?id) { if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON)) { return(new HttpStatusCodeResult(403)); } BL.Route r = MainClass.Instance.getRoutes().Find(v => v.id == id); if (r != null) { System.Web.HttpContext.Current.Session["startPointLatitude"] = r.startPoint.latitude; System.Web.HttpContext.Current.Session["startPointLongitude"] = r.startPoint.longitude; r.startPoint.saveInDB(); System.Web.HttpContext.Current.Session["endPointLatitude"] = r.endPoint.latitude; System.Web.HttpContext.Current.Session["endPointLongitude"] = r.endPoint.longitude; r.endPoint.saveInDB(); return(View(new RouteModel() { driveTimeMinutes = r.driveTimeMinutes, endPointName = r.endPoint.name, startPointName = r.startPoint.name, name = r.getRouteString(), pointList = new List <RouteLatLongModel>() { new RouteLatLongModel() { latitude = (double)r.startPoint.latitude, longitude = (double)r.startPoint.longitude, title = "Start Point", zIndex = 0 }, new RouteLatLongModel() { latitude = (double)r.endPoint.latitude, longitude = (double)r.endPoint.longitude, title = "End Point", zIndex = 1 } } })); } return(new HttpNotFoundResult()); }