diff --git a/RentACar/Data/Models/Car.cs b/RentACar/Data/Models/Car.cs index 39918ff..2ecb9cc 100644 --- a/RentACar/Data/Models/Car.cs +++ b/RentACar/Data/Models/Car.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,16 +11,21 @@ namespace Data.Entities { public int Id { get; set; } + [Required] public string Brand { get; set; } + [Required] public string Model { get; set; } + [Required] public int Year { get; set; } + [Required] public int CountPassengerSeats { get; set; } public string Description { get; set; } + [Required] public decimal PriceForDay { get; set; } } } diff --git a/RentACar/WebApp/Controllers/CarsController.cs b/RentACar/WebApp/Controllers/CarsController.cs index 1f1bed3..a4cd610 100644 --- a/RentACar/WebApp/Controllers/CarsController.cs +++ b/RentACar/WebApp/Controllers/CarsController.cs @@ -57,7 +57,7 @@ namespace WebApp.Controllers // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public async Task Create([Bind("Id,Brand,Model,Year,CountPassengerSeats,Description,PriceForDay")] Car car) + public async Task Create([Bind("Id, Brand, Model, Year, CountPassengerSeats, Description, PriceForDay")] Car car) { if (ModelState.IsValid) { @@ -90,7 +90,7 @@ namespace WebApp.Controllers // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public async Task Edit(int id, [Bind("Id,Brand,Model,Year,CountPassengerSeats,Description,PriceForDay")] Car car) + public async Task Edit(int id, [Bind("Id, Brand, Model, Year, CountPassengerSeats, Description, PriceForDay")] Car car) { if (id != car.Id) { diff --git a/RentACar/WebApp/Views/Cars/Create.cshtml b/RentACar/WebApp/Views/Cars/Create.cshtml index c502ce0..f459283 100644 --- a/RentACar/WebApp/Views/Cars/Create.cshtml +++ b/RentACar/WebApp/Views/Cars/Create.cshtml @@ -32,6 +32,7 @@ diff --git a/RentACar/WebApp/Views/Shared/_Layout.cshtml b/RentACar/WebApp/Views/Shared/_Layout.cshtml index dc4fc4e..d89e475 100644 --- a/RentACar/WebApp/Views/Shared/_Layout.cshtml +++ b/RentACar/WebApp/Views/Shared/_Layout.cshtml @@ -24,12 +24,9 @@ - @if (this.User.IsInRole("Admin")) - { - } diff --git a/RentACar/WebApp/Views/Shared/_LoginPartial.cshtml b/RentACar/WebApp/Views/Shared/_LoginPartial.cshtml index d45564f..dc41016 100644 --- a/RentACar/WebApp/Views/Shared/_LoginPartial.cshtml +++ b/RentACar/WebApp/Views/Shared/_LoginPartial.cshtml @@ -7,7 +7,7 @@ @if (SignInManager.IsSignedIn(User)) {