fixed crash on car renting
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PriceForDay)
|
||||
</th>
|
||||
<th></th>
|
||||
<th>
|
||||
Select
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -57,6 +59,9 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PriceForDay)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-controller="Rents" asp-action="Create">Select</a>
|
||||
</td>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
<td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user