diff --git a/CarService/CarServiceDatabase/Models/ItemForRepair.cs b/CarService/CarServiceDatabase/Models/ItemForRepair.cs index 60a1132..450c6aa 100644 --- a/CarService/CarServiceDatabase/Models/ItemForRepair.cs +++ b/CarService/CarServiceDatabase/Models/ItemForRepair.cs @@ -22,6 +22,11 @@ namespace CarServiceDatabase.Models { return null; } + var currItem = context.Items.First(x => x.Id == model.ItemId); + if (currItem.Count < model.Count) + { + throw new ArgumentException("На складе нет столько запчастей"); + } return new() { Count = model.Count, diff --git a/CarService/CarServiceWebApp/Controllers/HomeController.cs b/CarService/CarServiceWebApp/Controllers/HomeController.cs index 5c3f2f6..2ce9f57 100644 --- a/CarService/CarServiceWebApp/Controllers/HomeController.cs +++ b/CarService/CarServiceWebApp/Controllers/HomeController.cs @@ -148,7 +148,7 @@ namespace CarServiceWebApp.Controllers /// Отображение формы добавления работы /// /// - //[HttpGet] + [HttpGet] public IActionResult CreateWork() => View(); /// /// Добавление работы