public async Task <IActionResult> Park(ParkParkedVehicleViewModel viewModel) { var parkSpots = ParkingSpotContainer.GetParkSpots(_configuration); if (ModelState.IsValid) { var vehicle = new ParkedVehicle(); vehicle.VehicleTypeId = int.Parse(Request.Form["Type"].ToString()); if (vehicle.VehicleTypeId == 0) { throw new ArgumentException("The value of the SelectItem selected was zero."); } var member = TempDataExtensions.Get <Member>(TempData, "member"); vehicle.MemberId = member.MemberId; PopulateVehicleFromViewModel(viewModel, vehicle); await ParkVehicleInBackend(parkSpots, vehicle); vehicle.IsParked = true; _context.Add(vehicle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public IActionResult Maintenance() { var response = TempDataExtensions.Get <KitsuneStatusResponse>(TempData, "kitsuneStatus"); if (response == null) { response = Helpers.KitsuneApiStatusCheck(TempData); if (response.Success && !response.IsDown) { return(RedirectToAction("Index", "Home")); } } ViewBag.kitsuneStatus = response; return(View("Maintenance")); }
public IActionResult ParkingReceipt() { var vehicle = TempDataExtensions.Get <ParkedVehicle>(TempData, "vehicle"); if (vehicle == null) { throw new Exception("JsonConvert failed to convert TempData"); } DateTime currentTime; TimeSpan parkingDuration; decimal cost; GetParkingCost(vehicle, out currentTime, out parkingDuration, out cost); var member = _context.Members.FirstOrDefault(m => m.MemberId == vehicle.MemberId); var memberFullName = member.FullName; var model = new Tuple <ParkedVehicle, DateTime, TimeSpan, decimal, string>(vehicle, currentTime, parkingDuration, cost, memberFullName); return(View(model)); }