From d5bfb168247779c37e3b884c0f22dbd2676bd153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Thu, 25 May 2023 12:24:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8,=20=D1=87=D1=82=D0=BE=20=D0=B7=D0=B0=D0=BF=D1=87=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D0=B9=20=D1=85=D0=B2=D0=B0=D1=82=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CarService/CarServiceDatabase/Models/ItemForRepair.cs | 5 +++++ CarService/CarServiceWebApp/Controllers/HomeController.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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(); /// /// Добавление работы