// GET: ParkingSpots/Create public ActionResult Create(CreateParkingSpotsVM viewModel) { ViewBag.SelectVehicleTypes = PopulateSelectLists.PopulateVehicleTypes(); return(View(new CreateParkingSpotsVM { DefaultFees = new DefaultFeesRepository().DefaultFees().ToList() })); }
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)); }
// 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)); }
// 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)); }
// 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)); }
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 })); }
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() })); }