From 2c3b04226c93d1b8c8e12bfd48adf43d276297f2 Mon Sep 17 00:00:00 2001 From: ekallin Date: Sun, 7 Apr 2024 20:47:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=BA=20=D0=B2=D1=80=D0=BE=D0=B4=D0=B5?= =?UTF-8?q?=20=D0=B2=D1=81=D0=B5=20=D0=BA=D1=80=D0=B0=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE=20=D0=B8=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=BE=D0=B4=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/Shops/FormAddSushiInShop.Designer.cs | 2 +- SushiBar/Shops/FormAddSushiInShop.cs | 3 ++- SushiBarBusinessLogic/OrderLogic.cs | 8 ++++---- SushiBarBusinessLogic/ShopLogic.cs | 12 ++++++------ SushiBarFileImplement/Implements/ShopStorage.cs | 4 +++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/SushiBar/Shops/FormAddSushiInShop.Designer.cs b/SushiBar/Shops/FormAddSushiInShop.Designer.cs index 84dd31f..f0ab7a5 100644 --- a/SushiBar/Shops/FormAddSushiInShop.Designer.cs +++ b/SushiBar/Shops/FormAddSushiInShop.Designer.cs @@ -129,7 +129,7 @@ Font = new Font("Candara", 10.8F, FontStyle.Regular, GraphicsUnit.Point, 204); Margin = new Padding(4); Name = "FormAddSushiInShop"; - Text = "FormAddSushiInShop"; + Text = "Пополняем магазинчик"; Load += FormAddSushiInShop_Load; ResumeLayout(false); PerformLayout(); diff --git a/SushiBar/Shops/FormAddSushiInShop.cs b/SushiBar/Shops/FormAddSushiInShop.cs index 0ce25db..77f0d3a 100644 --- a/SushiBar/Shops/FormAddSushiInShop.cs +++ b/SushiBar/Shops/FormAddSushiInShop.cs @@ -48,7 +48,8 @@ namespace SushiBarView.Shops if (!operationResult) { - throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах."); + MessageBox.Show("Не получилось почему-то добавить суши", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); diff --git a/SushiBarBusinessLogic/OrderLogic.cs b/SushiBarBusinessLogic/OrderLogic.cs index 0432661..f146af8 100644 --- a/SushiBarBusinessLogic/OrderLogic.cs +++ b/SushiBarBusinessLogic/OrderLogic.cs @@ -77,13 +77,13 @@ namespace SushiBarBusinessLogic.BusinessLogic if (order == null) { _logger.LogWarning("Change status operation failed. Order not found"); - return false; + throw new ArgumentNullException("Не найден заказ... "); } if (order.Status + 1 != orderStatus) { _logger.LogWarning("Change status operation failed. Incorrect new status: {orderStatus}. Current status: {Status}", orderStatus, order.Status); - return false; + throw new ArgumentException("Вы не можете перевести заказ в статус ", nameof(orderStatus)); } if(order.Status == OrderStatus.Готов) { @@ -91,12 +91,12 @@ namespace SushiBarBusinessLogic.BusinessLogic if (sushi == null) { _logger.LogWarning("Status change error. Sushi not found"); - return false; + throw new ArgumentNullException("Суши не нашлись такие... "); } if (!CheckSupply(sushi, order.Count)) { _logger.LogWarning("Status change error. Shop is overflowed"); - return false; + throw new ArgumentOutOfRangeException("Вы не можете выдать заказ, амбары переполнены "); } } model.Status = orderStatus; diff --git a/SushiBarBusinessLogic/ShopLogic.cs b/SushiBarBusinessLogic/ShopLogic.cs index 68672c4..dbe1066 100644 --- a/SushiBarBusinessLogic/ShopLogic.cs +++ b/SushiBarBusinessLogic/ShopLogic.cs @@ -88,9 +88,9 @@ namespace SushiBarBusinessLogic public bool AddSushiInShop(ShopSearchModel model, ISushiModel sushi, int count) { if (model == null) - throw new ArgumentNullException(nameof(model)); + throw new ArgumentNullException("Не найден такой магазин... \n", nameof(model)); if (count <= 0) - throw new ArgumentException("Количество суши должно быть больше нуля, ало", nameof(count)); + throw new ArgumentException("Количество суши должно быть больше нуля, ало \n", nameof(count)); _logger.LogInformation("Добавлены суши в магазин: {ShopName}.Id:{ Id}", model.ShopName, model.Id); var element = _shopStorage.GetElement(model); @@ -103,7 +103,7 @@ namespace SushiBarBusinessLogic if (element.MaxCountSushis - countSushis < count) { _logger.LogWarning("В магазине не хватает места"); - return false; + throw new ArgumentOutOfRangeException("Не зватает места в магазинах, увы... кушать меньше надо ", nameof(countSushis)); } if (element.ShopSushis.TryGetValue(sushi.Id, out var samesushi)) { @@ -133,11 +133,11 @@ namespace SushiBarBusinessLogic { if (sushi == null) { - throw new ArgumentNullException(nameof(sushi)); + throw new ArgumentNullException("Не найдены такие суши, их нет в магазинах... \n", nameof(sushi)); } if (count <= 0) { - throw new ArgumentNullException("Количество суши должно быть больше нуля! алло!", nameof(count)); + throw new ArgumentNullException("Количество суши должно быть больше нуля! алло!\n", nameof(count)); } if (_shopStorage.SellSushis(sushi, count)) { @@ -156,7 +156,7 @@ namespace SushiBarBusinessLogic if (!withParams) return; if (string.IsNullOrEmpty(model.ShopName)) { - throw new ArgumentNullException("Нет такого магазина", nameof(model.ShopName)); + throw new ArgumentNullException("Нет такого магазина ", nameof(model.ShopName)); } _logger.LogInformation("Shop. ShopName:{ShopName}.Address:{ Address}. Id:{ Id}", model.ShopName, model.Address, model.Id); diff --git a/SushiBarFileImplement/Implements/ShopStorage.cs b/SushiBarFileImplement/Implements/ShopStorage.cs index 8ce8341..0de0470 100644 --- a/SushiBarFileImplement/Implements/ShopStorage.cs +++ b/SushiBarFileImplement/Implements/ShopStorage.cs @@ -79,7 +79,7 @@ namespace SushiBarFileImplement.Implements var sushi = _source.Sushis.FirstOrDefault(x => x.Id == model.Id); if (sushi == null || !CheckCountSushi(model, count)) { - return false; + throw new ArgumentNullException("Такого количества суш нет, продать столько низя "); } foreach (var shop in _source.Shops) @@ -93,6 +93,8 @@ namespace SushiBarFileImplement.Implements if (count <= 0) { + //throw new ArgumentNullException("Такого количества суш нет, продать столько низя "); + break; } }