public ActionResult LogIn(string username, string password)
        {
            DatabaseInterface db = new DatabaseInterface();
             User user = db.GetUser(username, password);
             if (user == null)
             {
            return Json(new
            {
               error = true,
               message = "Invalid username or password"
            });
             }
             FormsAuthentication.SetAuthCookie(user.Id.ToString(), false);
             sessionManager.User = user;
             var model = new OutputViewModel()
             {
            Username = user.Username,
            Routes = db.GetAvailableRoutes(),
            Buses = db.GetAvailableBuses(),
            Employees = db.GetAvailableEmployees(),
            Stops = db.GetAvailableStops(),
            Drivers = db.GetAvailableDrivers()
             };

             return Json(new
             {
            user = JsonUtility.ToUserJson(user),
            headerText = "Welcome, " + model.Username,
            html = RenderPartialViewToString("AdminView", model)
             });
        }
 public ActionResult LoadView()
 {
     var user = sessionManager.User;
     if (user == null)
     {
         return PartialView("Login");
     }
     DatabaseInterface db = new DatabaseInterface();
     var model = new OutputViewModel()
     {
         Username = user.Username,
         Routes = db.GetAvailableRoutes(),
         Buses = db.GetAvailableBuses(),
         Employees = db.GetAvailableEmployees(),
         Stops = db.GetAvailableStops(),
         Drivers = db.GetAvailableDrivers()
     };
     return PartialView("AdminView", model);
 }
 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 ActionResult AddEmployee()
 {
     DatabaseInterface db = new DatabaseInterface();
     AddEmployeeModel model = new AddEmployeeModel()
     {
         AvailableRoutes = db.GetAvailableRoutes(),
         StateNames = stateNames,
         StateAbbreviations = stateAbbreviations
     };
     return PartialView("AddEmployee", model);
 }