fixed crash on car renting

This commit is contained in:
Dimitar Todorov
2022-04-07 21:58:11 +03:00
parent 6f246bff8b
commit 7a352c35f6
10 changed files with 52 additions and 550 deletions

View File

@@ -44,7 +44,7 @@ namespace WebApp.Controllers
}
// GET: Rents/Create
public IActionResult Create()
public IActionResult Create(int id)
{
return View();
}
@@ -58,6 +58,8 @@ namespace WebApp.Controllers
{
if (ModelState.IsValid)
{
var car = _context.Cars.FirstOrDefault(car => car.Id == 1);
rents.Car = car;
_context.Add(rents);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));