Esempio n. 1
0
        // GET: ParkingSpots/Create
        public ActionResult Create(CreateParkingSpotsVM viewModel)
        {
            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes();

            return(View(new CreateParkingSpotsVM
            {
                DefaultFees = new DefaultFeesRepository().DefaultFees().ToList()
            }));
        }
Esempio n. 2
0
        public ActionResult Edit([Bind(Include = "ID,OwnerID,RegistrationPlate,VehicleTypeID")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                db.Edit(vehicle);
                return(RedirectToAction("DisplayAllVehicles", "Garage"));
            }

            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(vehicle.VehicleTypeID);
            ViewBag.SelectOwners       = PopulateSelectLists.PopulateOwners(vehicle.OwnerID);

            return(View(vehicle));
        }
Esempio n. 3
0
        // GET: ParkingSpots/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ParkingSpot parkingSpot = db.ParkingSpot(id);

            if (parkingSpot == null)
            {
                return(HttpNotFound());
            }

            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(parkingSpot.VehicleTypeID);
            return(View(parkingSpot));
        }
Esempio n. 4
0
        // GET: Vehicles/Create
        public ActionResult Create(CreateVehicleVM viewModel)
        {
            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes();
            ViewBag.SelectOwners       = PopulateSelectLists.PopulateOwners();

            if (viewModel.OriginActionName == null)
            {
                viewModel.OriginActionName = "DisplayAllVehicles";
            }

            if (viewModel.OriginControllerName == null)
            {
                viewModel.OriginControllerName = "Garage";
            }

            return(View(viewModel));
        }
Esempio n. 5
0
        // GET: Vehicles/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Vehicle vehicle = db.Vehicle(id);

            if (vehicle == null)
            {
                return(HttpNotFound());
            }

            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(vehicle.VehicleTypeID);
            ViewBag.SelectOwners       = PopulateSelectLists.PopulateOwners(vehicle.OwnerID);

            return(View(vehicle));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "ID,OwnerID,RegistrationPlate,VehicleTypeID")] Vehicle vehicle,
                                   string originActionName,
                                   string originControllerName)
        {
            if (ModelState.IsValid)
            {
                // Check that the registration plate is still unique
                if (db.VehicleByRegistrationPlate(vehicle.RegistrationPlate) != null)
                {
                    ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(vehicle.VehicleTypeID);
                    ViewBag.SelectOwners       = PopulateSelectLists.PopulateOwners(vehicle.OwnerID);

                    return(View(new CreateVehicleVM
                    {
                        Vehicle = vehicle,
                        OriginControllerName = originControllerName,
                        OriginActionName = originActionName,
                        ErrorMessage = "A vehicle with the same registration plate already exists!"
                    }));
                }

                vehicle.RegistrationPlate = vehicle.RegistrationPlate.ToUpper();

                db.Add(vehicle);
                return(RedirectToAction(originActionName, originControllerName, new SelectAVehicleVM
                {
                    VehicleID = vehicle.ID
                }));
            }

            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(vehicle.VehicleTypeID);
            ViewBag.SelectOwners       = PopulateSelectLists.PopulateOwners(vehicle.OwnerID);

            return(View(new CreateVehicleVM
            {
                Vehicle = vehicle,
                OriginControllerName = originControllerName,
                OriginActionName = originActionName
            }));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "ID,Label,Fee,VehicleTypeID")] ParkingSpot parkingSpot)
        {
            DefaultFeesRepository dfr = new DefaultFeesRepository();

            if (ModelState.IsValid)
            {
                // Check that the label is still unique
                if (db.ParkingSpotByIdentifiant(parkingSpot.Label) != null)
                {
                    ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes();

                    return(View(new CreateParkingSpotsVM
                    {
                        ParkingSpot = parkingSpot,
                        DefaultFees = dfr.DefaultFees(),
                        ErrorMessage = "A parking spot with the same identifiant already exists!"
                    }));
                }

                if (parkingSpot.Fee == null)
                {
                    parkingSpot.Fee = dfr.DefaultFeeByVehicleTypeID(parkingSpot.VehicleTypeID).Fee;
                }

                db.Add(parkingSpot);
                return(RedirectToAction("Index"));
            }

            ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes();

            return(View(new CreateParkingSpotsVM
            {
                ParkingSpot = parkingSpot,
                DefaultFees = dfr.DefaultFees()
            }));
        }