Lazy Loading fix, new migration, Rents Index data
This commit is contained in:
@@ -61,6 +61,7 @@ namespace WebApp.Controllers
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Create(Rents rents)
|
||||
{
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var car = _context.Cars.FirstOrDefault(car => car.Id == 1);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace API
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<RentACarDbContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
|
||||
options.UseLazyLoadingProxies().UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
|
||||
services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
services.AddIdentity<User, IdentityRole>(options =>
|
||||
{
|
||||
@@ -45,7 +45,6 @@ namespace API
|
||||
.AddDefaultUI()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddEntityFrameworkStores<RentACarDbContext>();
|
||||
|
||||
services.AddControllersWithViews();
|
||||
services.AddRazorPages();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
ID
|
||||
@Html.DisplayNameFor(model => model.Id)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Brand)
|
||||
@@ -27,13 +27,13 @@
|
||||
@Html.DisplayNameFor(model => model.Year)
|
||||
</th>
|
||||
<th>
|
||||
Seats
|
||||
@Html.DisplayNameFor(model => model.CountPassengerSeats)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Description)
|
||||
</th>
|
||||
<th>
|
||||
Daily price
|
||||
@Html.DisplayNameFor(model => model.PriceForDay)
|
||||
</th>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
|
||||
@@ -9,18 +9,72 @@
|
||||
<div>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Car.Id)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Car.Id)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Car.Brand)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Car.Brand)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Car.Model)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Car.Model)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Car.CountPassengerSeats)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Car.CountPassengerSeats)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Car.PriceForDay)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Car.PriceForDay)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.StartDate)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.StartDate)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.EndDate)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.EndDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.User.FirstName)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.User.FirstName)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.User.LastName)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.User.LastName)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.User.UserName)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.User.UserName)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.User.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.User.Email)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Car ID
|
||||
@Html.DisplayNameFor(model => model.Car.Id)
|
||||
</th>
|
||||
<th>
|
||||
Start Date
|
||||
@Html.DisplayNameFor(model => model.StartDate)
|
||||
</th>
|
||||
<th>
|
||||
End Date
|
||||
@Html.DisplayNameFor(model => model.EndDate)
|
||||
</th>
|
||||
<th>
|
||||
User
|
||||
@Html.DisplayNameFor(model => model.User.UserName)
|
||||
</th>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
@@ -37,28 +37,28 @@
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Car.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.StartDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EndDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.User.UserName)
|
||||
</td>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
@Html.DisplayFor(modelItem => item.Car.Id)
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.StartDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EndDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.User.UserName)
|
||||
</td>
|
||||
@if (this.User.IsInRole("Admin"))
|
||||
{
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -13,22 +13,22 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
First name
|
||||
@Html.DisplayNameFor(model => model.FirstName)
|
||||
</th>
|
||||
<th>
|
||||
Last name
|
||||
@Html.DisplayNameFor(model => model.LastName)
|
||||
</th>
|
||||
<th>
|
||||
ID number
|
||||
@Html.DisplayNameFor(model => model.PersonalNumber)
|
||||
</th>
|
||||
<th>
|
||||
Username
|
||||
@Html.DisplayNameFor(model => model.UserName)
|
||||
</th>
|
||||
<th>
|
||||
E-mail
|
||||
@Html.DisplayNameFor(model => model.Email)
|
||||
</th>
|
||||
<th>
|
||||
Phone number
|
||||
@Html.DisplayNameFor(model => model.PhoneNumber)
|
||||
</th>
|
||||
<th>
|
||||
Actions
|
||||
|
||||
Reference in New Issue
Block a user