From 1dc0aa3682acf0bee5567f5877fbfc00fa863a4e Mon Sep 17 00:00:00 2001 From: "ani_konarcheva@abv.bg" Date: Wed, 6 Apr 2022 17:31:48 +0300 Subject: [PATCH] CarsController --- RentACar/Data/Data/RentACarDbContext.cs | 2 +- .../Identity/Pages/Account/Register.cshtml | 5 +++ .../Identity/Pages/Account/Register.cshtml.cs | 5 ++- RentACar/WebApp/Views/Cars/Create.cshtml | 12 +---- RentACar/WebApp/Views/Cars/Index.cshtml | 45 ++++++++++--------- RentACar/WebApp/Views/Home/Index.cshtml | 2 +- RentACar/WebApp/Views/Shared/_Layout.cshtml | 14 ++---- RentACar/WebApp/appsettings.json | 2 +- .../WebApp/bin/Debug/net5.0/appsettings.json | 2 +- 9 files changed, 43 insertions(+), 46 deletions(-) diff --git a/RentACar/Data/Data/RentACarDbContext.cs b/RentACar/Data/Data/RentACarDbContext.cs index fc96388..a5fb4f3 100644 --- a/RentACar/Data/Data/RentACarDbContext.cs +++ b/RentACar/Data/Data/RentACarDbContext.cs @@ -20,7 +20,7 @@ namespace Data { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer("Server=.;Database=RentACar;Integrated Security=true;"); + optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=RentACar;Integrated Security=true;"); } } diff --git a/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml b/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml index c1b1454..d213306 100644 --- a/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml +++ b/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml @@ -37,6 +37,11 @@ +
+ + + +
diff --git a/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml.cs b/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml.cs index 58b591a..b451f3f 100644 --- a/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/RentACar/WebApp/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -65,6 +65,9 @@ namespace WebApp.Areas.Identity.Pages.Account [Display(Name = "Phone")] public string PhoneNumber { get; set; } + [Display(Name = "Personal number")] + public string PersonalNumber { get; set; } + [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] @@ -89,7 +92,7 @@ namespace WebApp.Areas.Identity.Pages.Account ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { - var user = new User { Id = Guid.NewGuid().ToString(), UserName = Input.Username, Email = Input.Email, FirstName = Input.FirstName, LastName = Input.LastName, PhoneNumber = Input.PhoneNumber }; + var user = new User { Id = Guid.NewGuid().ToString(), UserName = Input.Username, Email = Input.Email, FirstName = Input.FirstName, LastName = Input.LastName, PhoneNumber = Input.PhoneNumber, PersonalNumber = Input.PersonalNumber }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { diff --git a/RentACar/WebApp/Views/Cars/Create.cshtml b/RentACar/WebApp/Views/Cars/Create.cshtml index 24f8184..c502ce0 100644 --- a/RentACar/WebApp/Views/Cars/Create.cshtml +++ b/RentACar/WebApp/Views/Cars/Create.cshtml @@ -4,9 +4,7 @@ ViewData["Title"] = "Create"; } -

Create

- -

Create new car

+

Create new vehicle


@@ -29,13 +27,7 @@
- +
diff --git a/RentACar/WebApp/Views/Cars/Index.cshtml b/RentACar/WebApp/Views/Cars/Index.cshtml index aa1d95b..4206c4d 100644 --- a/RentACar/WebApp/Views/Cars/Index.cshtml +++ b/RentACar/WebApp/Views/Cars/Index.cshtml @@ -4,11 +4,11 @@ ViewData["Title"] = "Cars"; } -

Index

+

Vehicle

@if (this.User.IsInRole("Admin")) { - New car + Create car }

@@ -38,30 +38,33 @@ @foreach (var item in Model) { - - - - - - - + + + + + + + + @if (this.User.IsInRole("Admin")) + { + } } diff --git a/RentACar/WebApp/Views/Home/Index.cshtml b/RentACar/WebApp/Views/Home/Index.cshtml index dbe286c..61c3e83 100644 --- a/RentACar/WebApp/Views/Home/Index.cshtml +++ b/RentACar/WebApp/Views/Home/Index.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Rent a car"; + ViewData["Title"] = "LuminousCars"; }
diff --git a/RentACar/WebApp/Views/Shared/_Layout.cshtml b/RentACar/WebApp/Views/Shared/_Layout.cshtml index ce2c717..dc4fc4e 100644 --- a/RentACar/WebApp/Views/Shared/_Layout.cshtml +++ b/RentACar/WebApp/Views/Shared/_Layout.cshtml @@ -11,7 +11,7 @@
- @Html.DisplayFor(modelItem => item.Brand) - - @Html.DisplayFor(modelItem => item.Model) - - @Html.DisplayFor(modelItem => item.Year) - - @Html.DisplayFor(modelItem => item.CountPassengerSeats) - - @Html.DisplayFor(modelItem => item.Description) - - @Html.DisplayFor(modelItem => item.PriceForDay) -
+ @Html.DisplayFor(modelItem => item.Brand) + + @Html.DisplayFor(modelItem => item.Model) + + @Html.DisplayFor(modelItem => item.Year) + + @Html.DisplayFor(modelItem => item.CountPassengerSeats) + + @Html.DisplayFor(modelItem => item.Description) + + @Html.DisplayFor(modelItem => item.PriceForDay) + Edit | Details | Delete