// GET: Rents/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var user = HttpContext.User.Identity.Name; var cars = await _context.Cars .SingleOrDefaultAsync(m => m.IdCar == id); if (cars == null) { return(NotFound()); } cars.Available = false; Rent s = new Rent { Login = user, IdCar = id }; _context.Update(cars); await _context.SaveChangesAsync(); _context.Add(s); await _context.SaveChangesAsync(); var cars2 = await _context.Cars .SingleOrDefaultAsync(m => m.IdCar == id); return(View(cars2)); }
public async Task <IActionResult> Edit(int id, [Bind("IdCar,Mark,Model,Category,Available")] Cars cars) { if (id != cars.IdCar) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cars); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarsExists(cars.IdCar)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cars)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,CarRegNo,CarMake,CarModel,Year,ImageUrl,PricePerDay")] Car car) { if (id != car.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(car); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(car.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(car)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,UserName")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(string id, [Bind("BookingId,CarId,UserId,NumberOfDays")] Booking booking) { if (id != booking.BookingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(booking); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(booking.BookingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarId"] = new SelectList(_context.Set <Car>(), "Id", "Id", booking.CarId); ViewData["UserId"] = new SelectList(_context.Set <User>(), "Id", "Id", booking.UserId); return(View(booking)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,DriverName,CarId")] Driver driver) { if (id != driver.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(driver); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DriverExists(driver.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarId"] = new SelectList(_context.Car, "Id", "Id", driver.CarId); return(View(driver)); }