commiting some changes
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Data
|
|||||||
{
|
{
|
||||||
if (!optionsBuilder.IsConfigured)
|
if (!optionsBuilder.IsConfigured)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer("Server=.;Database=RentACar;Integrated Security=true;");
|
optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Data.Entities
|
|||||||
public class Car
|
public class Car
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ namespace WebApp.Controllers
|
|||||||
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Create([Bind("Id,StartDate,EndDate")] Rents rents)
|
public async Task<IActionResult> Create([Bind("Id,CarId,StartDate,EndDate,UserId")] Rents rents)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
var car = _context.Cars.FirstOrDefault(car => car.Id == 1);
|
var car = _context.Cars.FirstOrDefault(car => car.Id == rents.CarId);
|
||||||
rents.Car = car;
|
rents.Car = car;
|
||||||
_context.Add(rents);
|
_context.Add(rents);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@@ -88,7 +88,7 @@ namespace WebApp.Controllers
|
|||||||
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Edit(int id, [Bind("Id,StartDate,EndDate")] Rents rents)
|
public async Task<IActionResult> Edit(int id, [Bind("Id,CarId,StartDate,EndDate,UserId")] Rents rents)
|
||||||
{
|
{
|
||||||
if (id != rents.Id)
|
if (id != rents.Id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace API
|
|||||||
options.Password.RequireNonAlphanumeric = false;
|
options.Password.RequireNonAlphanumeric = false;
|
||||||
options.Password.RequireUppercase = true;
|
options.Password.RequireUppercase = true;
|
||||||
|
|
||||||
options.User.RequireUniqueEmail = false;
|
options.User.RequireUniqueEmail = true;
|
||||||
})
|
})
|
||||||
.AddRoles<IdentityRole>()
|
.AddRoles<IdentityRole>()
|
||||||
.AddDefaultUI()
|
.AddDefaultUI()
|
||||||
@@ -78,6 +78,7 @@ namespace API
|
|||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
endpoints.MapRazorPages();
|
endpoints.MapRazorPages();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.Id)
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Brand)
|
@Html.DisplayNameFor(model => model.Brand)
|
||||||
</th>
|
</th>
|
||||||
@@ -40,36 +43,39 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Brand)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Model)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Year)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.CountPassengerSeats)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Description)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.PriceForDay)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a asp-controller="Rents" asp-action="Create">Select</a>
|
|
||||||
</td>
|
|
||||||
@if (this.User.IsInRole("Admin"))
|
|
||||||
{
|
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
|
||||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
|
||||||
</td>
|
</td>
|
||||||
}
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Brand)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Model)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Year)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.CountPassengerSeats)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Description)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.PriceForDay)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a asp-controller="Rents" asp-action="Create">Select</a>
|
||||||
|
</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>
|
</tbody>
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form asp-action="Create">
|
<form asp-action="Create">
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
<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>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="StartDate" class="control-label"></label>
|
<label asp-for="StartDate" class="control-label"></label>
|
||||||
<input asp-for="StartDate" class="form-control" />
|
<input asp-for="StartDate" class="form-control" />
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.CarId)
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.StartDate)
|
@Html.DisplayNameFor(model => model.StartDate)
|
||||||
</th>
|
</th>
|
||||||
@@ -25,6 +28,9 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model) {
|
@foreach (var item in Model) {
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.CarId)
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.StartDate)
|
@Html.DisplayFor(modelItem => item.StartDate)
|
||||||
</td>
|
</td>
|
||||||
@@ -39,7 +45,7 @@
|
|||||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Server=.;Database=RentACar;Integrated Security=true;"
|
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
Reference in New Issue
Block a user