Page design, remove migration, edit foreign key

This commit is contained in:
Dimitar Byalkov
2022-04-08 19:22:12 +03:00
parent 6ab09ad841
commit 7a888a4c2e
16 changed files with 163 additions and 1214 deletions

View File

@@ -4,19 +4,18 @@
ViewData["Title"] = "Cars";
}
<h1>Vehicle</h1>
<h2>Available cars</h2>
<h1>Vehicles</h1>
<p>
@if (this.User.IsInRole("Admin"))
{
<a asp-action="Create">Create car</a>
<a type="button" class="btn btn-primary" asp-action="Create">Add new car</a>
}
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Id)
ID
</th>
<th>
@Html.DisplayNameFor(model => model.Brand)
@@ -28,16 +27,16 @@
@Html.DisplayNameFor(model => model.Year)
</th>
<th>
@Html.DisplayNameFor(model => model.CountPassengerSeats)
Seats
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.PriceForDay)
Daily price
</th>
<th>
Select
Actions
</th>
</tr>
</thead>
@@ -66,9 +65,6 @@
<td>
@Html.DisplayFor(modelItem => item.PriceForDay)
</td>
<td>
<a asp-controller="Rents" asp-action="Create" >Select</a>
</td>
@if (this.User.IsInRole("Admin"))
{
<td>

View File

@@ -3,5 +3,11 @@
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h1 class="display-4">Welcome, @User.Identity.Name</h1>
<br />
<a type="button" class="btn btn-primary" asp-area="" asp-controller="Cars" asp-action="Index">Manage cars</a>
@if (this.User.IsInRole("Admin"))
{
<a type="button" class="btn btn-primary" asp-area="" asp-controller="Rents" asp-action="Index">Manage rents</a>
}
</div>

View File

@@ -1,6 +0,0 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@@ -4,19 +4,17 @@
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Rents</h4>
<h1>Create rent</h1>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="CarId" class="control-label"></label>
<input asp-for="CarId" class="form-control" />
<span asp-validation-for="CarId" class="text-danger"></span>
<label asp-for="Car.Id" class="control-label"></label>
<input asp-for="Car.Id" class="form-control" />
<span asp-validation-for="Car.Id" class="text-danger"></span>
</div>
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="StartDate" class="control-label"></label>
<input asp-for="StartDate" class="form-control" />
@@ -38,6 +36,8 @@
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@@ -0,0 +1,34 @@
@model Data.Entities.Rents
@{
ViewData["Title"] = "DateSelect";
}
<h1>Rent a car</h1>
<h2>Select dates</h2>
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="StartDate" class="control-label"></label>
<input asp-for="StartDate" class="form-control" />
<span asp-validation-for="StartDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="EndDate" class="control-label"></label>
<input asp-for="EndDate" class="form-control" />
<span asp-validation-for="EndDate" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Findiew" class="btn btn-primary" />
</div>
</form>
</div>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@@ -4,30 +4,53 @@
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h1>Delete rent</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Rents</h4>
<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.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>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-action="Index">Back to List</a>
<input type="submit" value="Delete" class="btn btn-danger" />
<a class="btn btn-secondary" asp-action="Index">Back to List</a>
</form>
</div>

View File

@@ -7,7 +7,6 @@
<h1>Details</h1>
<div>
<h4>Rents</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@@ -25,6 +24,6 @@
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
<a class="btn btn-primary" asp-action="Edit" asp-route-id="@Model.Id">Edit</a>
<a class="btn btn-secondary" asp-action="Index">Back to List</a>
</div>

View File

@@ -4,15 +4,18 @@
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Rents</h4>
<h1>Edit rent</h1>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Car.Id" class="control-label"></label>
<input asp-for="Car.Id" class="form-control" />
<span asp-validation-for="Car.Id" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="StartDate" class="control-label"></label>
<input asp-for="StartDate" class="form-control" />
@@ -24,15 +27,13 @@
<span asp-validation-for="EndDate" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
<input class="btn btn-primary" type="submit" value="Save" />
<a class="btn btn-secondary" asp-action="Index">Back to List</a>
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

View File

@@ -7,44 +7,53 @@
<h1>Rents</h1>
<p>
<a asp-action="Create">Create New</a>
<a type="button" class="btn btn-primary" asp-action="Create">Rent a car</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.CarId)
</th>
<th>
@Html.DisplayNameFor(model => model.StartDate)
</th>
<th>
@Html.DisplayNameFor(model => model.EndDate)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CarId)
</td>
<td>
@Html.DisplayFor(modelItem => item.StartDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.EndDate)
</td>
@if (this.User.IsInRole("Admin"))
@if (this.User.IsInRole("Admin"))
{
<table class="table">
<thead>
<tr>
<th>
Car ID
</th>
<th>
Start Date
</th>
<th>
End Date
</th>
@if (this.User.IsInRole("Admin"))
{
<th>
Actions
</th>
}
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<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>
<td>
@Html.DisplayFor(modelItem => item.Car.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.StartDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.EndDate)
</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>
}
</tr>
}
</tbody>
</table>
</tbody>
</table>
}

View File

@@ -27,12 +27,6 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Rents" asp-action="Index">Rents</a>
</li>
@if (this.User.IsInRole("Admin"))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Users" asp-action="Index">Users</a>
</li>
}
</ul>
<partial name="_LoginPartial" />
</div>

View File

@@ -7,7 +7,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello, @User.Identity.Name</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Account</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })">