From f7e4f386baa919a13ae3343ba2df1d0f80ae8a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B0=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A4=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sat, 2 Mar 2024 15:52:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B1=D1=8B=D1=82=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=201=20=D1=83=D1=81=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D1=91=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarpentryWorkshop/FormMain.cs | 8 +-- ...pForm.Designer.cs => FormShop.Designer.cs} | 2 +- .../{ShopForm.cs => FormShop.cs} | 4 +- .../{ShopForm.resx => FormShop.resx} | 0 ...Form.Designer.cs => FormShops.Designer.cs} | 2 +- .../{ShopsForm.cs => FormShops.cs} | 12 ++-- .../{ShopsForm.resx => FormShops.resx} | 0 ...orm.Designer.cs => FormSupply.Designer.cs} | 10 ++- .../{SupplyForm.cs => FormSupply.cs} | 18 ++--- .../{SupplyForm.resx => FormSupply.resx} | 50 +++++++------- .../CarpentryWorkshop/Program.cs | 6 +- .../BusinessLogics/ShopLogic.cs | 65 +++++++++++++------ .../BindingModels/SupplyBindingModel .cs | 11 ++++ .../BusinessLogicsContracts/IShopLogic.cs | 2 +- .../SearchModels/ShopSearchModel.cs | 2 +- .../StoragesContracts/IShopStorage.cs | 1 - .../Models/ISupplyModel.cs | 9 +++ .../Implements/ShopStorage.cs | 14 ++-- .../Models/Shop.cs | 4 +- 19 files changed, 135 insertions(+), 85 deletions(-) rename CarpentryWorkshop/CarpentryWorkshop/{ShopForm.Designer.cs => FormShop.Designer.cs} (99%) rename CarpentryWorkshop/CarpentryWorkshop/{ShopForm.cs => FormShop.cs} (97%) rename CarpentryWorkshop/CarpentryWorkshop/{ShopForm.resx => FormShop.resx} (100%) rename CarpentryWorkshop/CarpentryWorkshop/{ShopsForm.Designer.cs => FormShops.Designer.cs} (99%) rename CarpentryWorkshop/CarpentryWorkshop/{ShopsForm.cs => FormShops.cs} (94%) rename CarpentryWorkshop/CarpentryWorkshop/{ShopsForm.resx => FormShops.resx} (100%) rename CarpentryWorkshop/CarpentryWorkshop/{SupplyForm.Designer.cs => FormSupply.Designer.cs} (91%) rename CarpentryWorkshop/CarpentryWorkshop/{SupplyForm.cs => FormSupply.cs} (88%) rename CarpentryWorkshop/CarpentryWorkshop/{SupplyForm.resx => FormSupply.resx} (93%) create mode 100644 CarpentryWorkshop/CarpentryWorkshopContracts/BindingModels/SupplyBindingModel .cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopDataModels/Models/ISupplyModel.cs diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs index cfc3fdc..3a3039d 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs @@ -154,8 +154,8 @@ namespace CarpentryWorkshopView private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(ShopsForm)); - if (service is ShopsForm form) + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) { form.ShowDialog(); } @@ -163,8 +163,8 @@ namespace CarpentryWorkshopView private void поставкиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(SupplyForm)); - if (service is SupplyForm form) + var service = Program.ServiceProvider?.GetService(typeof(FormSupply)); + if (service is FormSupply form) { form.ShowDialog(); } diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopForm.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormShop.Designer.cs similarity index 99% rename from CarpentryWorkshop/CarpentryWorkshop/ShopForm.Designer.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormShop.Designer.cs index 9a265ac..a11fedc 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/ShopForm.Designer.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormShop.Designer.cs @@ -1,6 +1,6 @@ namespace CarpentryWorkshopView { - partial class ShopForm + partial class FormShop { /// /// Required designer variable. diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopForm.cs b/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs similarity index 97% rename from CarpentryWorkshop/CarpentryWorkshop/ShopForm.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormShop.cs index 954210b..0076e41 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/ShopForm.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs @@ -6,13 +6,13 @@ using Microsoft.Extensions.Logging; namespace CarpentryWorkshopView { - public partial class ShopForm : Form + public partial class FormShop : Form { private readonly ILogger _logger; private readonly IShopLogic _logic; public int? _id; private Dictionary _woods; - public ShopForm(ILogger logger, IShopLogic logic) + public FormShop(ILogger logger, IShopLogic logic) { InitializeComponent(); _logger = logger; diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopForm.resx b/CarpentryWorkshop/CarpentryWorkshop/FormShop.resx similarity index 100% rename from CarpentryWorkshop/CarpentryWorkshop/ShopForm.resx rename to CarpentryWorkshop/CarpentryWorkshop/FormShop.resx diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopsForm.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormShops.Designer.cs similarity index 99% rename from CarpentryWorkshop/CarpentryWorkshop/ShopsForm.Designer.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormShops.Designer.cs index ef41ce2..ec39f29 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/ShopsForm.Designer.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormShops.Designer.cs @@ -1,6 +1,6 @@ namespace CarpentryWorkshopView { - partial class ShopsForm + partial class FormShops { /// /// Required designer variable. diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopsForm.cs b/CarpentryWorkshop/CarpentryWorkshop/FormShops.cs similarity index 94% rename from CarpentryWorkshop/CarpentryWorkshop/ShopsForm.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormShops.cs index 10ac590..cbe1cd6 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/ShopsForm.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormShops.cs @@ -5,11 +5,11 @@ using Microsoft.Extensions.Logging; namespace CarpentryWorkshopView { - public partial class ShopsForm : Form + public partial class FormShops : Form { private readonly ILogger _logger; private readonly IShopLogic _logic; - public ShopsForm(ILogger logger, IShopLogic logic) + public FormShops(ILogger logger, IShopLogic logic) { InitializeComponent(); _logger = logger; @@ -45,8 +45,8 @@ namespace CarpentryWorkshopView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(ShopForm)); - if (service is ShopForm form) + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) { if (form.ShowDialog() == DialogResult.OK) { @@ -59,8 +59,8 @@ namespace CarpentryWorkshopView { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(ShopForm)); - if (service is ShopForm form) + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) { var tmp = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); form._id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); diff --git a/CarpentryWorkshop/CarpentryWorkshop/ShopsForm.resx b/CarpentryWorkshop/CarpentryWorkshop/FormShops.resx similarity index 100% rename from CarpentryWorkshop/CarpentryWorkshop/ShopsForm.resx rename to CarpentryWorkshop/CarpentryWorkshop/FormShops.resx diff --git a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.Designer.cs similarity index 91% rename from CarpentryWorkshop/CarpentryWorkshop/SupplyForm.Designer.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormSupply.Designer.cs index 44383fc..5f858ea 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.Designer.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.Designer.cs @@ -1,6 +1,6 @@ namespace CarpentryWorkshopView { - partial class SupplyForm + partial class FormSupply { /// /// Required designer variable. @@ -42,6 +42,8 @@ ShopComboBox.Name = "ShopComboBox"; ShopComboBox.Size = new Size(331, 23); ShopComboBox.TabIndex = 0; + ShopComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + ShopComboBox.FormattingEnabled = true; // // WoodComboBox // @@ -50,6 +52,8 @@ WoodComboBox.Name = "WoodComboBox"; WoodComboBox.Size = new Size(331, 23); WoodComboBox.TabIndex = 1; + WoodComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + WoodComboBox.FormattingEnabled = true; // // CountTextBox // @@ -78,7 +82,7 @@ CancelButton.UseVisualStyleBackColor = true; CancelButton.Click += CancelButton_Click; // - // SupplyForm + // FormSupply // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; @@ -88,7 +92,7 @@ Controls.Add(CountTextBox); Controls.Add(WoodComboBox); Controls.Add(ShopComboBox); - Name = "SupplyForm"; + Name = "FormSupply"; Text = "SupplyForm"; ResumeLayout(false); PerformLayout(); diff --git a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.cs b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.cs similarity index 88% rename from CarpentryWorkshop/CarpentryWorkshop/SupplyForm.cs rename to CarpentryWorkshop/CarpentryWorkshop/FormSupply.cs index ca539be..ba71e4b 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.cs @@ -1,4 +1,5 @@ -using CarpentryWorkshopContracts.BusinessLogicsContracts; +using CarpentryWorkshopContracts.BindingModels; +using CarpentryWorkshopContracts.BusinessLogicsContracts; using CarpentryWorkshopContracts.SearchModels; using CarpentryWorkshopContracts.ViewModels; using CarpentryWorkshopDataModels.Models; @@ -14,7 +15,7 @@ using System.Windows.Forms; namespace CarpentryWorkshopView { - public partial class SupplyForm : Form + public partial class FormSupply : Form { private readonly List? _woodList; private readonly List? _shopsList; @@ -71,7 +72,7 @@ namespace CarpentryWorkshopView set { CountTextBox.Text = value.ToString(); } } - public SupplyForm(IWoodLogic woodLogic, IShopLogic shopLogic) + public FormSupply(IWoodLogic woodLogic, IShopLogic shopLogic) { InitializeComponent(); _shopLogic = shopLogic; @@ -119,11 +120,12 @@ namespace CarpentryWorkshopView { int count = Convert.ToInt32(CountTextBox.Text); - bool res = _shopLogic.MakeSupply( - new ShopSearchModel() { Id = Convert.ToInt32(ShopComboBox.SelectedValue) }, - _woodLogic.ReadElement(new() { Id = Convert.ToInt32(WoodComboBox.SelectedValue) }), - count - ); + bool res = _shopLogic.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(ShopComboBox.SelectedValue), + WoodId = Convert.ToInt32(WoodComboBox.SelectedValue), + Count = Convert.ToInt32(CountTextBox.Text) + }); if (!res) { diff --git a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.resx b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.resx similarity index 93% rename from CarpentryWorkshop/CarpentryWorkshop/SupplyForm.resx rename to CarpentryWorkshop/CarpentryWorkshop/FormSupply.resx index 1af7de1..af32865 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/SupplyForm.resx +++ b/CarpentryWorkshop/CarpentryWorkshop/FormSupply.resx @@ -1,17 +1,17 @@  - diff --git a/CarpentryWorkshop/CarpentryWorkshop/Program.cs b/CarpentryWorkshop/CarpentryWorkshop/Program.cs index 021c482..56b3301 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/Program.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/Program.cs @@ -53,9 +53,9 @@ namespace CarpentryWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs b/CarpentryWorkshop/CarpentryWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs index 4d50c2f..dbd73e0 100644 --- a/CarpentryWorkshop/CarpentryWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs +++ b/CarpentryWorkshop/CarpentryWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs @@ -12,18 +12,19 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics { private readonly ILogger _logger; private readonly IShopStorage _shopStorage; + private readonly IWoodStorage _woodStorage; - public ShopLogic(ILogger logger, IShopStorage shopStorage) + public ShopLogic(ILogger logger, IShopStorage shopStorage, IWoodStorage woodStorage) { _logger = logger; _shopStorage = shopStorage; + _woodStorage = woodStorage; } public List ReadList(ShopSearchModel model) { - _logger.LogInformation("ReadList. ShopName:{Name}. Id:{ Id}", model?.Name, model?.Id); - var list = model == null ? _shopStorage.GetFullList() : - _shopStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -31,14 +32,45 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics } _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; - } - public bool MakeSupply(ShopSearchModel model, IWoodModel wood, int count) + public bool MakeSupply(SupplyBindingModel model) { if (model == null) - return false; - return _shopStorage.SupplyWood(model, wood, count); + { + throw new ArgumentNullException(nameof(model)); + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий должно быть больше 0"); + } + var shop = _shopStorage.GetElement(new ShopSearchModel + { + Id = model.ShopId + }); + if (shop == null) + { + throw new ArgumentException("Магазина не существует"); + } + if (shop.ShopWoods.ContainsKey(model.WoodId)) + { + var oldValue = shop.ShopWoods[model.WoodId]; + oldValue.Item2 += model.Count; + shop.ShopWoods[model.WoodId] = oldValue; + } + else + { + var wood = _woodStorage.GetElement(new WoodSearchModel + { + Id = model.WoodId + }); + if (wood == null) + { + throw new ArgumentException($"Поставка: Товар с id:{model.WoodId} не найденн"); + } + shop.ShopWoods.Add(model.WoodId, (wood, model.Count)); + } + return true; } public ShopViewModel ReadElement(ShopSearchModel model) @@ -47,7 +79,7 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id); + _logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id); var element = _shopStorage.GetElement(model); if (element == null) { @@ -101,23 +133,18 @@ namespace CarpentryWorkshopBusinessLogic.BusinessLogics { return; } - if (string.IsNullOrEmpty(model.ShopName)) - { - throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName)); - } if (string.IsNullOrEmpty(model.Address)) { - throw new ArgumentNullException("Нет адресса магазина", nameof(model.ShopName)); + throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Address)); } - if (model.DateOpen == null) + if (string.IsNullOrEmpty(model.ShopName)) { - throw new ArgumentNullException("Нет даты открытия магазина", - nameof(model.ShopName)); + throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName)); } - _logger.LogInformation("Shop. ShopName:{ShopName}.Address:{Address}. DateOpen:{DateOpen}. Id: { Id}", model.ShopName, model.Address, model.DateOpen, model.Id); + _logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Address, model.DateOpen, model.Id); var element = _shopStorage.GetElement(new ShopSearchModel { - Name = model.ShopName + ShopName = model.ShopName }); if (element != null && element.Id != model.Id) { diff --git a/CarpentryWorkshop/CarpentryWorkshopContracts/BindingModels/SupplyBindingModel .cs b/CarpentryWorkshop/CarpentryWorkshopContracts/BindingModels/SupplyBindingModel .cs new file mode 100644 index 0000000..d824da7 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshopContracts/BindingModels/SupplyBindingModel .cs @@ -0,0 +1,11 @@ +using CarpentryWorkshopDataModels.Models; + +namespace CarpentryWorkshopContracts.BindingModels +{ + public class SupplyBindingModel : ISupplyModel + { + public int ShopId { get; set; } + public int WoodId { get; set; } + public int Count { get; set; } + } +} diff --git a/CarpentryWorkshop/CarpentryWorkshopContracts/BusinessLogicsContracts/IShopLogic.cs b/CarpentryWorkshop/CarpentryWorkshopContracts/BusinessLogicsContracts/IShopLogic.cs index df5d729..5840f0f 100644 --- a/CarpentryWorkshop/CarpentryWorkshopContracts/BusinessLogicsContracts/IShopLogic.cs +++ b/CarpentryWorkshop/CarpentryWorkshopContracts/BusinessLogicsContracts/IShopLogic.cs @@ -12,6 +12,6 @@ namespace CarpentryWorkshopContracts.BusinessLogicsContracts bool Create(ShopBindingModel model); bool Update(ShopBindingModel model); bool Delete(ShopBindingModel model); - bool MakeSupply(ShopSearchModel model, IWoodModel wood, int count); + bool MakeSupply(SupplyBindingModel model); } } diff --git a/CarpentryWorkshop/CarpentryWorkshopContracts/SearchModels/ShopSearchModel.cs b/CarpentryWorkshop/CarpentryWorkshopContracts/SearchModels/ShopSearchModel.cs index 1398bb7..71d0ee2 100644 --- a/CarpentryWorkshop/CarpentryWorkshopContracts/SearchModels/ShopSearchModel.cs +++ b/CarpentryWorkshop/CarpentryWorkshopContracts/SearchModels/ShopSearchModel.cs @@ -3,6 +3,6 @@ public class ShopSearchModel { public int? Id { get; set; } - public string? Name { get; set; } + public string? ShopName { get; set; } } } diff --git a/CarpentryWorkshop/CarpentryWorkshopContracts/StoragesContracts/IShopStorage.cs b/CarpentryWorkshop/CarpentryWorkshopContracts/StoragesContracts/IShopStorage.cs index f5a59d6..465cef8 100644 --- a/CarpentryWorkshop/CarpentryWorkshopContracts/StoragesContracts/IShopStorage.cs +++ b/CarpentryWorkshop/CarpentryWorkshopContracts/StoragesContracts/IShopStorage.cs @@ -18,6 +18,5 @@ namespace CarpentryWorkshopContracts.StoragesContracts ShopViewModel? Insert(ShopBindingModel model); ShopViewModel? Update(ShopBindingModel model); ShopViewModel? Delete(ShopBindingModel model); - bool SupplyWood(ShopSearchModel model, IWoodModel wood, int Count); } } diff --git a/CarpentryWorkshop/CarpentryWorkshopDataModels/Models/ISupplyModel.cs b/CarpentryWorkshop/CarpentryWorkshopDataModels/Models/ISupplyModel.cs new file mode 100644 index 0000000..8d0e414 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshopDataModels/Models/ISupplyModel.cs @@ -0,0 +1,9 @@ +namespace CarpentryWorkshopDataModels.Models +{ + public interface ISupplyModel + { + int ShopId { get; } + int WoodId { get; } + int Count { get; } + } +} diff --git a/CarpentryWorkshop/CarpentryWorkshopListImplement/Implements/ShopStorage.cs b/CarpentryWorkshop/CarpentryWorkshopListImplement/Implements/ShopStorage.cs index df27e7a..5f6c4c4 100644 --- a/CarpentryWorkshop/CarpentryWorkshopListImplement/Implements/ShopStorage.cs +++ b/CarpentryWorkshop/CarpentryWorkshopListImplement/Implements/ShopStorage.cs @@ -27,13 +27,13 @@ namespace CarpentryWorkshopListImplement.Implements model) { var result = new List(); - if (string.IsNullOrEmpty(model.Name)) + if (string.IsNullOrEmpty(model.ShopName)) { return result; } foreach (var shop in _source.Shops) { - if (shop.ShopName.Contains(model.Name)) + if (shop.ShopName.Contains(model.ShopName)) { result.Add(shop.GetViewModel); } @@ -42,14 +42,14 @@ namespace CarpentryWorkshopListImplement.Implements } public ShopViewModel? GetElement(ShopSearchModel model) { - if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) { return null; } foreach (var shop in _source.Shops) { - if ((!string.IsNullOrEmpty(model.Name) && - shop.ShopName == model.Name) || + if ((!string.IsNullOrEmpty(model.ShopName) && + shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) { return shop.GetViewModel; @@ -101,7 +101,7 @@ namespace CarpentryWorkshopListImplement.Implements return null; } - public bool SupplyWood(ShopSearchModel model, IWoodModel wood, int count) + /* public bool SupplyWood(ShopSearchModel model, IWoodModel wood, int count) { if (model == null) throw new ArgumentNullException(nameof(model)); @@ -130,6 +130,6 @@ namespace CarpentryWorkshopListImplement.Implements ShopWoods = curModel.ShopWoods, }); return true; - } + } */ } } diff --git a/CarpentryWorkshop/CarpentryWorkshopListImplement/Models/Shop.cs b/CarpentryWorkshop/CarpentryWorkshopListImplement/Models/Shop.cs index 23cae3b..1b9426b 100644 --- a/CarpentryWorkshop/CarpentryWorkshopListImplement/Models/Shop.cs +++ b/CarpentryWorkshop/CarpentryWorkshopListImplement/Models/Shop.cs @@ -26,8 +26,7 @@ namespace CarpentryWorkshopListImplement.Models Id = model.Id, ShopName = model.ShopName, Address = model.Address, - DateOpen = model.DateOpen, - ShopWoods = new() + DateOpen = model.DateOpen }; } @@ -40,7 +39,6 @@ namespace CarpentryWorkshopListImplement.Models ShopName = model.ShopName; Address = model.Address; DateOpen = model.DateOpen; - ShopWoods = model.ShopWoods; } public ShopViewModel GetViewModel => new()