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; } }