public ActionResult AddLocation(LocationModel locationModel) { if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON)) { return(new HttpStatusCodeResult(403)); } decimal latitude = (decimal)System.Web.HttpContext.Current.Session["mapLatitude"]; decimal longitude = (decimal)System.Web.HttpContext.Current.Session["mapLongitude"]; if (ModelState.IsValid) { BL.LatLongCoordinate point = new BL.LatLongCoordinate(latitude, longitude, locationModel.name); point.saveInDB(); if (MainClass.Instance.addLocation(new Location(point, locationModel.name))) { ViewBag.Message = "Location added successfully"; ViewBag.Status = true; return(initialLocationView()); } } ViewBag.Message = "Location could not be added"; ViewBag.Status = false; return(initialLocationView()); }
public ActionResult AddRoute(RouteModel routeModel) { if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON)) { return(new HttpStatusCodeResult(403)); } if (ModelState.IsValid) { decimal longitude = (decimal)System.Web.HttpContext.Current.Session["startPointLongitude"]; decimal latitude = (decimal)System.Web.HttpContext.Current.Session["startPointLongitude"]; BL.LatLongCoordinate startPoint = new BL.LatLongCoordinate( (decimal)System.Web.HttpContext.Current.Session["startPointLatitude"], (decimal)System.Web.HttpContext.Current.Session["startPointLongitude"], routeModel.startPointName); startPoint.saveInDB(); BL.LatLongCoordinate endPoint = new BL.LatLongCoordinate( (decimal)System.Web.HttpContext.Current.Session["endPointLatitude"], (decimal)System.Web.HttpContext.Current.Session["endPointLongitude"], routeModel.endPointName); endPoint.saveInDB(); if (MainClass.Instance.addRoute(new BL.Route(startPoint, endPoint, routeModel.driveTimeMinutes))) { ViewBag.Message = "Successfully added route"; ViewBag.Status = true; return(initialRouteView()); } } ViewBag.Message = "Route could not be added"; ViewBag.Status = false; return(initialRouteView()); }