public async Task <IActionResult> UnParkConfirmed(string RegNum) { var vehicle = await _context.ParkedVehicles.FindAsync(RegNum); var vehicleType = await _context.VehicleTypes.FirstOrDefaultAsync(t => t.Id == vehicle.VehicleTypeId); var spotsRequired = GetRequiredNumberOfSpots(vehicleType); if (vehicle != null) { vehicle.IsParked = false; _context.Update(vehicle); await _context.SaveChangesAsync(); } else { throw new ArgumentNullException(nameof(vehicle), "The vehicle could not be found in the database."); } ParkSpot spot; // TODO: More elegant solution without extra calls to FindSpotByVehicle for (var i = 0; i < spotsRequired; i++) { spot = ParkingSpotContainer.FindSpotByVehicle(vehicle); spot.Unpark(vehicle); } TempDataExtensions.Set(TempData, "vehicle", vehicle); TempData.Keep(); return(RedirectToAction(nameof(ParkingReceipt))); }
public IActionResult CheckEmail(EmailAddress emailAddress) { var result = _context.Members.FirstOrDefault(m => m.Email == emailAddress.Email); if (result != null) { TempDataExtensions.Set(TempData, "member", result); TempData.Keep(); return(RedirectToAction(nameof(VehiclesController.Park), "Vehicles")); } return(RedirectToAction(nameof(RegistrationRequired))); }