From 69cdb744c9806dcf112da238ef3b9ca50e71ff5d Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Thu, 23 May 2024 23:03:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B8=D0=B7=D0=B8=D1=82=D1=8B=20=D1=84?= =?UTF-8?q?=D1=83=D0=BB.=20=D0=BF=D1=80=D0=B8=D1=81=D1=82=D1=83=D0=BF?= =?UTF-8?q?=D0=B0=D1=8E=20=D0=BA=20=D0=BB=D0=B5=D0=BA=D0=B0=D1=80=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/VisitLogic.cs | 17 ++++++++++++++++- .../Controllers/HomeController.cs | 11 +++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs index 554dd7d..5f7c205 100644 --- a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs +++ b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs @@ -60,7 +60,22 @@ namespace VeterinaryBusinessLogic.BusinessLogic } public bool Update(VisitBindingModel model) { - CheckModel(model); + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (string.IsNullOrEmpty(model.VisitName)) + { + throw new ArgumentNullException("Нет названия визита", nameof(model.VisitName)); + } + var element = _visitStorage.GetElement(new VisitSearchModel + { + VisitName = model.VisitName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Визит с таким названием уже есть"); + } if (_visitStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); diff --git a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs index 146e5c4..3f6a22f 100644 --- a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs @@ -287,7 +287,7 @@ namespace VeterinaryShowOwnerApp.Controllers } [HttpPost] - public void UpdateVisit(int visit, string name, List pets) + public void UpdateVisit(int visit, string name) { if (APIOwner.Owner == null) { @@ -297,18 +297,13 @@ namespace VeterinaryShowOwnerApp.Controllers { throw new Exception("Ошибка в введенных данных"); } - Dictionary a = new Dictionary(); - foreach (int pet in pets) - { - a.Add(pet, new PetSearchModel { Id = pet } as IPetModel); - } APIOwner.PostRequest("api/visit/updatevisit", new VisitBindingModel { Id = visit, VisitName = name, - VisitPet = a + OwnerId = APIOwner.Owner.Id, }); - Response.Redirect("Index"); + Response.Redirect("Visits"); } [HttpGet] public Tuple>? GetVisit(int visitId)