Exemplo n.º 1
0
        public ActionResult SelectAParkingSpot(SelectAParkingSpotVM viewModel)
        {
            Vehicle vehicle = new GarageController().Vehicle(viewModel.VehicleID);

            if (vehicle == null)
            {
                return(RedirectToAction("BookAParkingSpot",
                                        "Vehicles",
                                        new
                {
                    checkIn = viewModel.CheckIn,
                    errorMessage = "You must select a vehicle!"
                }));
            }

            ParkingSpot parkingSpot = db.ParkingSpot(viewModel.ParkingSpotID);

            if (parkingSpot == null)
            {
                return(RedirectToAction("SelectAParkingSpot",
                                        new
                {
                    vehicleId = viewModel.VehicleID,
                    checkIn = viewModel.CheckIn,
                    errorMessage = "You must select a parking spot!"
                }));
            }

            if (viewModel.CheckIn)
            {
                return(RedirectToAction("VehicleCheckedIn",
                                        "CheckIns",
                                        new SelectAParkingSpotVM
                {
                    CheckIn = true,
                    ParkingSpotID = viewModel.ParkingSpotID,
                    VehicleID = viewModel.VehicleID
                }));
            }
            else
            {
                return(RedirectToAction("ParkingSpotBooked",
                                        "CheckIns",
                                        new SelectAParkingSpotVM
                {
                    ParkingSpotID = viewModel.ParkingSpotID,
                    VehicleID = viewModel.VehicleID
                }));
            }
        }
Exemplo n.º 2
0
        public ActionResult ParkingSpotBooked(SelectAParkingSpotVM viewModel)
        {
            // Check that the vehicle isn't already parked/hasn't booked a place
            if (db.CheckInByVehicle(viewModel.VehicleID) != null)
            {
                return(RedirectToAction("Index", "Garage"));
            }

            // Check in the vehicle ID to the parking spot
            CheckIn checkIn = db.Book(viewModel.VehicleID, viewModel.ParkingSpotID);

            checkIn.Vehicle     = new GarageController().Vehicle(viewModel.VehicleID);
            checkIn.ParkingSpot = new GarageController().ParkingSpot(viewModel.ParkingSpotID);

            // Displays the chosen parking spot
            return(View(checkIn));
        }
Exemplo n.º 3
0
        public ActionResult VehicleCheckedIn(SelectAParkingSpotVM viewModel)
        {
            // Check that the vehicle isn't already parked/hasn't booked a place
            if (db.CheckInByVehicle(viewModel.VehicleID) != null)
            {
                return(RedirectToAction("Index", "Garage"));
            }

            Vehicle vehicle = new GarageController().Vehicle(viewModel.VehicleID);

            if (vehicle == null)
            {
                return(RedirectToAction("BookAParkingSpot",
                                        "Vehicles",
                                        new
                {
                    checkIn = viewModel.CheckIn,
                    errorMessage = "You must select a vehicle!"
                }));
            }

            // Check in the vehicle ID to the parking spot
            ParkingSpot parkingSpot = new GarageController().ParkingSpot(viewModel.ParkingSpotID);

            if (parkingSpot == null)
            {
                return(RedirectToAction("CheckInAVehicle", new
                {
                    vehicleId = viewModel.VehicleID,
                    errorMessage = "You must select a parking spot!"
                }));
            }

            CheckIn checkIn = db.CheckIn(viewModel.VehicleID, viewModel.ParkingSpotID);

            checkIn.Vehicle     = vehicle;
            checkIn.ParkingSpot = parkingSpot;

            // Displays the chosen parking spot
            return(View(checkIn));
        }