public ActionResult UpdateRoute(int routeId, List<int> stopIds, string routeName, int busId, string driverLicense)
 {
     DatabaseInterface db = new DatabaseInterface();
     String sRouteId = routeId.ToString();
     if (!db.IsRouteNameUnique(routeName, sRouteId))
         return Json("false");
     List<Stop> stops = new List<Stop>();
     foreach (int id in stopIds)
     {
         stops.Add(db.GetStopByStopId(id));
     }
     db.AssignBusToRoute(busId, routeId);
     db.AssignDriverToRoute(driverLicense, routeId);
     Route route = new Route()
     {
         Stops = stops,
         Driver = db.GetDriverByDriverLicense(driverLicense),
         Name = routeName,
         RouteId = routeId,
         Bus = db.GetBusByBusId(busId)
     };
     db.UpdateRoute(route);
     return Json("true");
 }
 public void AddRoute(Route route)
 {
     var coll = _database.GetCollection(_routeCollectionName);
     coll.Save(route);
 }
 public ActionResult AddNewRoute(List<int> stopIds, string routeName, int busId, bool startsAtWork, string driverLicense)
 {
     DatabaseInterface db = new DatabaseInterface();
     if (!db.IsRouteNameUnique(routeName))
         return Json("false");
     int routeId;
     if (startsAtWork)
         routeId = db.GetNextLowRouteId();
     else
         routeId = db.GetNextHighRouteId();
     List<Stop> stops = new List<Stop>();
     foreach (int id in stopIds)
     {
         stops.Add(db.GetStopByStopId(id));
     }
     List<Route> routes = new List<Route>();
     routes = db.GetAvailableRoutes();
     db.AssignBusToRoute(busId, routeId);
     db.AssignDriverToRoute(driverLicense, routeId);
     Route route = new Route()
     {
         Stops = stops,
         Driver = db.GetDriverByDriverLicense(driverLicense),
         Name = routeName,
         RouteId = routeId,
         Id = ObjectId.GenerateNewId(),
         Bus = db.GetBusByBusId(busId)
     };
     db.AddRoute(route);
     return Json(new
     {
        success = "true",
        id = route.Id.ToString()
     });
 }
 public void UpdateRoute(Route route)
 {
     var coll = _database.GetCollection(_routeCollectionName);
     coll.Remove(Query.EQ("RouteId", route.RouteId));
     coll.Save(route);
 }