public async Task <IActionResult> Edit(int id, [Bind("AutoId,AutoKenteken,AutoMerk,AutoType,EigenaarNaam")] Auto auto) { if (id != auto.AutoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(auto); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutoExists(auto.AutoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(auto)); }
public async Task <IActionResult> RePark(string registrationNumber) { var vehicle = await _context.ParkedVehicles.FirstOrDefaultAsync(v => v.RegistrationNumber.Equals(registrationNumber)); if (vehicle == null) { TempData.Keep(); return(RedirectToAction(nameof(Park))); } vehicle.ParkingDate = DateTime.Now; vehicle.IsParked = true; var parkSpots = ParkingSpotContainer.GetParkSpots(_configuration); await ParkVehicleInBackend(parkSpots, vehicle); try { _context.Update(vehicle); await _context.SaveChangesAsync(); return(RedirectToAction(actionName: "Index", controllerName: "Vehicles")); } catch (DbUpdateConcurrencyException) { if (await _context.ParkedVehicles.FirstOrDefaultAsync(v => v.RegistrationNumber == registrationNumber) == null) { TempData.Keep(); return(RedirectToAction(nameof(Park))); } else { throw; } } return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,CityAddress,Email,PhoneNumber")] MemberEditViewModel model) { if (id != model.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var member = await _context.Members.FirstOrDefaultAsync(m => m.MemberId == model.Id); mapper.Map(model, member); if (member != null) { _context.Update(member); await _context.SaveChangesAsync(); } else { return(NotFound()); } } catch (DbUpdateConcurrencyException) { if (!_context.Members.Any(m => m.MemberId == id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id })); } return(View(model)); }