From 1ee31d12676a58cb8225c026f3b85ab1d946858a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Mar 2023 12:23:46 +0400 Subject: [PATCH] fix --- FoodOrders/FoodOrders/FormDeliveryDishes.cs | 21 +++++++++---------- .../BusinessLogics/ShopLogic.cs | 2 +- .../Implements/ShopStorage.cs | 4 +--- .../FoodOrdersListImplement/Models/Shop.cs | 8 ++----- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/FoodOrders/FoodOrders/FormDeliveryDishes.cs b/FoodOrders/FoodOrders/FormDeliveryDishes.cs index 3515156..a12c9ae 100644 --- a/FoodOrders/FoodOrders/FormDeliveryDishes.cs +++ b/FoodOrders/FoodOrders/FormDeliveryDishes.cs @@ -6,13 +6,13 @@ namespace FoodOrdersView public partial class FormDeliveryDishes : Form { private readonly ILogger _logger; - private readonly IDishLogic _logicC; + private readonly IDishLogic _logicD; private readonly IShopLogic _logicS; public FormDeliveryDishes(ILogger logger, IDishLogic logicC, IShopLogic logicS) { InitializeComponent(); _logger = logger; - _logicC = logicC; + _logicD = logicC; _logicS = logicS; } private void FormDeliveryDishes_Load(object sender, EventArgs e) @@ -37,7 +37,7 @@ namespace FoodOrdersView _logger.LogInformation("Загрузка блюд"); try { - var list = _logicC.ReadList(null); + var list = _logicD.ReadList(null); if (list != null) { comboBoxDish.DisplayMember = "DishName"; @@ -72,24 +72,23 @@ namespace FoodOrdersView _logger.LogInformation("Пополнение магазина"); try { - var operationResult = _logicS.DeliveryDishes(new ShopSearchModel - { - ShopName = comboBoxShop.Text, - }, _logicC.ReadElement(new DishSearchModel{ DishName = comboBoxDish.Text })!, Convert.ToInt32(textBoxCount.Text)); + var operationResult = _logicS.DeliveryDishes( + new ShopSearchModel { ShopName = comboBoxShop.Text,}, + _logicD.ReadElement(new DishSearchModel{ DishName = comboBoxDish.Text })!, + Convert.ToInt32(textBoxCount.Text) + ); if (!operationResult) { throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах."); } - MessageBox.Show("Пополнение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Пополнение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { _logger.LogError(ex, "Ошибка пополнения магазина"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ShopLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ShopLogic.cs index 4ce318d..d78a7ef 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ShopLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ShopLogic.cs @@ -62,7 +62,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics } if (element.ShopDishes.ContainsKey(dish.Id)) { - element.ShopDishes[dish.Id] = (element.ShopDishes[dish.Id].Item1, element.ShopDishes[dish.Id].Item2 + count); + element.ShopDishes[dish.Id] = (dish, element.ShopDishes[dish.Id].Item2 + count); } else { diff --git a/FoodOrders/FoodOrdersListImplement/Implements/ShopStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/ShopStorage.cs index d34dd88..f8f414a 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/ShopStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/ShopStorage.cs @@ -34,9 +34,7 @@ namespace FoodOrdersListImplement.Implements } foreach (var shop in _source.Shops) { - if ((!string.IsNullOrEmpty(model.ShopName) && - shop.ShopName == model.ShopName) || - (model.Id.HasValue && shop.Id == model.Id)) + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) { return shop.GetViewModel; } diff --git a/FoodOrders/FoodOrdersListImplement/Models/Shop.cs b/FoodOrders/FoodOrdersListImplement/Models/Shop.cs index c3bd475..04d3119 100644 --- a/FoodOrders/FoodOrdersListImplement/Models/Shop.cs +++ b/FoodOrders/FoodOrdersListImplement/Models/Shop.cs @@ -8,15 +8,11 @@ namespace FoodOrdersListImplement.Models { public class Shop : IShopModel { + public int Id { get; private set; } public string ShopName { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty; public DateTime DateOfOpening { get; private set; } = DateTime.Now; - public int Id { get; private set; } - public Dictionary ShopDishes - { - get; - private set; - } = new Dictionary(); + public Dictionary ShopDishes { get; private set; } = new Dictionary(); public static Shop? Create(ShopBindingModel? model) { if (model == null)