Ejemplo n.º 1
0
        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)
             });
        }
Ejemplo n.º 2
0
 public ActionResult ModifyRoute(String routeId)
 {
     DatabaseInterface db = new DatabaseInterface();
     Route route = db.GetRouteByRouteId(int.Parse(routeId));
     AddRouteModel model = new AddRouteModel()
     {
         AvailableBuses = db.GetAvailableBuses(),
         AvailableStops = db.GetAvailableStops(),
         AvailableDrivers = db.GetAvailableDrivers(),
         Bus = route.Bus,
         Driver = route.Driver,
         Name = route.Name,
         RouteId = routeId,
         Stops = route.Stops,
         UpdatingRoute = true
     };
     return PartialView("AddRoute", model);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public ActionResult AddRoute()
 {
     DatabaseInterface db = new DatabaseInterface();
     AddRouteModel model = new AddRouteModel()
     {
         AvailableBuses = db.GetAvailableBuses(),
         AvailableStops = db.GetAvailableStops(),
         AvailableDrivers = db.GetAvailableDrivers(),
         Bus = null,
         Driver = null,
         Name = "",
         RouteId = "",
         Stops = { },
         UpdatingRoute = false
     };
     return PartialView("AddRoute", model);
 }