diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs
deleted file mode 100644
index 9e07955..0000000
--- a/SushiBar/SushiBar/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace SushiBar
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run();
- }
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/SushiBar.csproj b/SushiBar/SushiBar/SushiBar.csproj
deleted file mode 100644
index b57c89e..0000000
--- a/SushiBar/SushiBar/SushiBar.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic/App.config b/SushiBar/SushiBarBusinessLogic/App.config
deleted file mode 100644
index 56efbc7..0000000
--- a/SushiBar/SushiBarBusinessLogic/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs
deleted file mode 100644
index f4885e5..0000000
--- a/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarBusinessLogic.BusinessLogics
-{
- public class ComponentLogic
- private readonly ILogger _logger;
- private readonly IComponentStorage _componentStorage;
- public ComponentLogic(ILogger logger, IComponentStorage
- componentStorage)
- {
- _logger = logger;
- _componentStorage = componentStorage;
- }
- public List? ReadList(ComponentSearchModel? model)
- {
- _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id);
- var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
- public ComponentViewModel? ReadElement(ComponentSearchModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id} ", model.ComponentName, model.Id);
- var element = _componentStorage.GetElement(model);
- if (element == null)
- {
- _logger.LogWarning("ReadElement element not found");
- return null;
- }
- _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
- return element;
- }
- public bool Create(ComponentBindingModel model)
- {
- CheckModel(model);
- if (_componentStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
- public bool Update(ComponentBindingModel model)
- {
- CheckModel(model);
- if (_componentStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- public bool Delete(ComponentBindingModel model)
- {
- CheckModel(model, false);
- _logger.LogInformation("Delete. Id:{Id}", model.Id);
- if (_componentStorage.Delete(model) == null)
- {
- _logger.LogWarning("Delete operation failed");
- return false;
- }
- return true;
- }
- private void CheckModel(ComponentBindingModel model, bool withParams =
- true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (string.IsNullOrEmpty(model.ComponentName))
- {
- throw new ArgumentNullException("Нет названия компонента",
- nameof(model.ComponentName));
- }
- if (model.Cost <= 0)
- {
- throw new ArgumentNullException("Цена компонента должна быть
- больше 0", nameof(model.Cost));
- }
- _logger.LogInformation("Component. ComponentName:{ComponentName}.
- Cost:{ Cost}. Id: { Id}
- ", model.ComponentName, model.Cost, model.Id);
- var element = _componentStorage.GetElement(new ComponentSearchModel
- {
- ComponentName = model.ComponentName
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Компонент с таким названием
- уже есть");
- }
- }
-}
diff --git a/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj b/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
deleted file mode 100644
index 166199b..0000000
--- a/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {E9064087-924C-4E00-A9EA-8E922CF49D11}
- Exe
- SushiBarBusinessLogic
- SushiBarBusinessLogic
- v4.7.2
- 512
- true
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
- {993e0787-3ad5-4743-8997-c828cd0cdc10}
- SushiBarContracts
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs
deleted file mode 100644
index 46d0d91..0000000
--- a/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.StoragesContracts;
-using SushiBarContracts.ViewModels;
-using SushiBarDataModels.Enums;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarBusinessLogic.BusinessLogics
-{
- public class ComponentLogic : IComponentLogic
- {
-
- private readonly ILogger _logger;
- private readonly IComponentStorage _componentStorage;
- public ComponentLogic(ILogger logger, IComponentStorage
- componentStorage)
- {
- _logger = logger;
- _componentStorage = componentStorage;
- }
- public List? ReadList(ComponentSearchModel? model)
- {
- _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id);
- var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
- public ComponentViewModel? ReadElement(ComponentSearchModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id} ", model.ComponentName, model.Id);
- var element = _componentStorage.GetElement(model);
- if (element == null)
- {
- _logger.LogWarning("ReadElement element not found");
- return null;
- }
- _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
- return element;
- }
- public bool Create(ComponentBindingModel model)
- {
- CheckModel(model);
- if (_componentStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
- public bool Update(ComponentBindingModel model)
- {
- CheckModel(model);
- if (_componentStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- public bool Delete(ComponentBindingModel model)
- {
- CheckModel(model, false);
- _logger.LogInformation("Delete. Id:{Id}", model.Id);
- if (_componentStorage.Delete(model) == null)
- {
- _logger.LogWarning("Delete operation failed");
- return false;
- }
- return true;
- }
- private void CheckModel(ComponentBindingModel model, bool withParams =
- true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (string.IsNullOrEmpty(model.ComponentName))
- {
- throw new ArgumentNullException("Нет названия компонента",
- nameof(model.ComponentName));
- }
- if (model.Cost <= 0)
- {
- throw new ArgumentNullException("Цена компонента должна больше 0", nameof(model.Cost));
- }
- _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id);
- var element = _componentStorage.GetElement(new ComponentSearchModel
- {
- ComponentName = model.ComponentName
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Компонент с таким названием уже есть");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs b/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs
deleted file mode 100644
index ac3e5f0..0000000
--- a/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.StoragesContracts;
-using SushiBarContracts.ViewModels;
-using SushiBarDataModels.Enums;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarBusinessLogic.BusinessLogics
-{
- public class OrderLogic : IOrderLogic
- {
- private readonly ILogger _logger;
- private readonly IOrderStorage _orderStorage;
- public OrderLogic(ILogger logger, IOrderStorage orderStorage)
- {
- _logger = logger;
- _orderStorage = orderStorage;
- }
- public List? ReadList(OrderSearchModel? model)
- {
- _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
- var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
- public bool CreateOrder(OrderBindingModel model)
- {
- CheckModel(model);
- if (model.Status != OrderStatus.Неизвестен)
- return false;
- model.Status = OrderStatus.Принят;
- if (_orderStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
-
- public bool TakeOrderInWork(OrderBindingModel model)
- {
- return ChangeStatus(model, OrderStatus.Выполняется);
- }
-
- public bool FinishOrder(OrderBindingModel model)
- {
- return ChangeStatus(model, OrderStatus.Готов);
- }
-
- public bool DeliveryOrder(OrderBindingModel model)
- {
- return ChangeStatus(model, OrderStatus.Выдан);
- }
-
- private void CheckModel(OrderBindingModel model, bool withParams = true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (model.Count <= 0)
- {
- throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count));
- }
- if (model.Sum <= 0)
- {
- throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum));
- }
- if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate)
- {
- throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}");
- }
- _logger.LogInformation("Sushi. SushiId:{SushiId}.Count:{Count}.Sum:{Sum}Id:{Id}",
- model.SushiId, model.Count, model.Sum, model.Id);
- }
-
- private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus)
- {
- CheckModel(model, false);
- var element = _orderStorage.GetElement(new OrderSearchModel()
- {
- Id = model.Id
- });
- if (element == null)
- {
- throw new ArgumentNullException(nameof(element));
- }
- model.DateCreate = element.DateCreate;
- model.SushiId = element.SushiId;
- model.DateImplement = element.DateImplement;
- model.Status = element.Status;
- model.Count = element.Count;
- model.Sum = element.Sum;
- if (requiredStatus - model.Status == 1)
- {
- model.Status = requiredStatus;
- if (model.Status == OrderStatus.Выдан)
- model.DateImplement = DateTime.Now;
- if (_orderStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
- throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
- }
- }
-}
diff --git a/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs b/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs
deleted file mode 100644
index fefe4a4..0000000
--- a/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BusinessLogicsContracts;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.StoragesContracts;
-using SushiBarContracts.ViewModels;
-
-namespace SushiBarBusinessLogic.BusinessLogics
-{
- public class SushiLogic :ISushiLogic
- {
- private readonly ILogger _logger;
- private readonly ISushiStorage _SushiStorage;
- public SushiLogic(ILogger logger, ISushiStorage SushiStorage)
- {
- _logger = logger;
- _SushiStorage = SushiStorage;
- }
- public List? ReadList(SushiSearchModel? model)
- {
- _logger.LogInformation("ReadList. SushiName:{SushiName}.Id:{ Id}", model?.SushiName, model?.Id);
- var list = model == null ? _SushiStorage.GetFullList() : _SushiStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
- public SushiViewModel? ReadElement(SushiSearchModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- _logger.LogInformation("ReadElement. SushiName:{SushiName}.Id:{ Id}", model.SushiName, model.Id);
- var element = _SushiStorage.GetElement(model);
- if (element == null)
- {
- _logger.LogWarning("ReadElement element not found");
- return null;
- }
- _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
- return element;
- }
- public bool Create(SushiBindingModel model)
- {
- CheckModel(model);
- if (_SushiStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
- public bool Update(SushiBindingModel model)
- {
- CheckModel(model);
- if (_SushiStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- public bool Delete(SushiBindingModel model)
- {
- CheckModel(model, false);
- _logger.LogInformation("Delete. Id:{Id}", model.Id);
- if (_SushiStorage.Delete(model) == null)
- {
- _logger.LogWarning("Delete operation failed");
- return false;
- }
- return true;
- }
- private void CheckModel(SushiBindingModel model, bool withParams = true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (string.IsNullOrEmpty(model.SushiName))
- {
- throw new ArgumentNullException("Нет названия пиццы", nameof(model.SushiName));
- }
- if (model.Price <= 0)
- {
- throw new ArgumentNullException("Цена пиццы должна быть больше 0", nameof(model.Price));
- }
- if (model.SushiComponents == null || model.SushiComponents.Count == 0)
- {
- throw new ArgumentNullException("Перечень ингредиентов не может быть пустым", nameof(model.SushiComponents));
- }
- _logger.LogInformation("Sushi. SushiName:{SushiName}.Price:{Price}.Id: { Id}", model.SushiName, model.Price, model.Id);
- var element = _SushiStorage.GetElement(new SushiSearchModel
- {
- SushiName = model.SushiName
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Пицца с таким названием уже есть");
- }
- }
- }
-}
diff --git a/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs
deleted file mode 100644
index 206930c..0000000
--- a/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SushiBarDataModels.Models;
-
-namespace SushiBarContracts.BindingModels
-{
- public class ComponentBindingModel : IComponentModel
- {
- public int Id { get; set; }
- public string ComponentName { get; set; } = string.Empty;
- public double Cost { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs
deleted file mode 100644
index ee30e84..0000000
--- a/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using SushiBarDataModels.Enums;
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.BindingModels
-{
- public class OrderBindingModel : IOrderModel
- {
- public int Id { get; set; }
- public int SushiId { get; set; }
- public int Count { get; set; }
- public double Sum { get; set; }
- public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
- public DateTime DateCreate { get; set; } = DateTime.Now;
- public DateTime? DateImplement { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs
deleted file mode 100644
index ce67161..0000000
--- a/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SushiBarDataModels.Models;
-
-namespace SushiBarContracts.BindingModels
-{
- public class SushiBindingModel : ISushiModel
- {
- public int Id { get; set; }
- public string SushiName { get; set; } = string.Empty;
- public double Price { get; set; }
- public Dictionary SushiComponents
- {
- get;
- set;
- } = new();
-
- }
-}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
deleted file mode 100644
index 5c2b515..0000000
--- a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.BusinessLogicsContracts
-{
- public interface IComponentLogic
- {
- List? ReadList(ComponentSearchModel? model);
- ComponentViewModel? ReadElement(ComponentSearchModel model);
- bool Create(ComponentBindingModel model);
- bool Update(ComponentBindingModel model);
- bool Delete(ComponentBindingModel model);
- }
-}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
deleted file mode 100644
index b90fb79..0000000
--- a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.BusinessLogicsContracts
-{
- public interface IOrderLogic
- {
- List? ReadList(OrderSearchModel? model);
- bool CreateOrder(OrderBindingModel model);
- bool TakeOrderInWork(OrderBindingModel model);
- bool FinishOrder(OrderBindingModel model);
- bool DeliveryOrder(OrderBindingModel model);
- }
-}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
deleted file mode 100644
index 32c732b..0000000
--- a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.BusinessLogicsContracts
-{
- public interface ISushiLogic
- {
- List? ReadList(SushiSearchModel? model);
- SushiViewModel? ReadElement(SushiSearchModel model);
- bool Create(SushiBindingModel model);
- bool Update(SushiBindingModel model);
- bool Delete(SushiBindingModel model);
- }
-
-}
diff --git a/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs
deleted file mode 100644
index a69687d..0000000
--- a/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.SearchModels
-{
- public class ComponentSearchModel
- {
- public int? Id { get; set; }
- public string? ComponentName { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs
deleted file mode 100644
index 98630db..0000000
--- a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.SearchModels
-{
- public class OrderSearchModel
- {
- public int? Id { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs
deleted file mode 100644
index 95d2732..0000000
--- a/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.SearchModels
-{
- public class SushiSearchModel
- {
- public int? Id { get; set; }
- public string? SushiName { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs
deleted file mode 100644
index a58deb5..0000000
--- a/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.StoragesContracts
-{
- public interface IComponentStorage
- {
- List GetFullList();
- List GetFilteredList(ComponentSearchModel model);
- ComponentViewModel? GetElement(ComponentSearchModel model);
- ComponentViewModel? Insert(ComponentBindingModel model);
- ComponentViewModel? Update(ComponentBindingModel model);
- ComponentViewModel? Delete(ComponentBindingModel model);
- }
-}
diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs
deleted file mode 100644
index 5d310e8..0000000
--- a/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.StoragesContracts
-{
- public interface IOrderStorage
- {
- List GetFullList();
- List GetFilteredList(OrderSearchModel model);
- OrderViewModel? GetElement(OrderSearchModel model);
- OrderViewModel? Insert(OrderBindingModel model);
- OrderViewModel? Update(OrderBindingModel model);
- OrderViewModel? Delete(OrderBindingModel model);
- }
-
-}
diff --git a/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs
deleted file mode 100644
index 3682ff7..0000000
--- a/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-
-namespace SushiBarContracts.StoragesContracts
-{
- public interface ISushiStorage
- {
- List GetFullList();
- List GetFilteredList(SushiSearchModel model);
- SushiViewModel? GetElement(SushiSearchModel model);
- SushiViewModel? Insert(SushiBindingModel model);
- SushiViewModel? Update(SushiBindingModel model);
- SushiViewModel? Delete(SushiBindingModel model);
- }
-
-}
diff --git a/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs
deleted file mode 100644
index 5b924c1..0000000
--- a/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.ViewModels
-{
- public class ComponentViewModel : IComponentModel
- {
- public int Id { get; set; }
-
- [DisplayName("Название компонента")]
- public string ComponentName { get; set; } = string.Empty;
-
- [DisplayName("Цена")]
- public double Cost { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs
deleted file mode 100644
index 36203b3..0000000
--- a/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using SushiBarDataModels.Enums;
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.ViewModels
-{
- public class OrderViewModel : IOrderModel
- {
- [DisplayName("Номер")]
- public int Id { get; set; }
-
- public int SushiId { get; set; }
-
- [DisplayName("Изделие")]
- public string SushiName { get; set; } = string.Empty;
-
- [DisplayName("Количество")]
- public int Count { get; set; }
-
- [DisplayName("Сумма")]
- public double Sum { get; set; }
-
- [DisplayName("Статус")]
- public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
-
- [DisplayName("Дата создания")]
- public DateTime DateCreate { get; set; } = DateTime.Now;
-
- [DisplayName("Дата выполнения")]
- public DateTime? DateImplement { get; set; }
- }
-}
diff --git a/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs
deleted file mode 100644
index 8f9608c..0000000
--- a/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SushiBarContracts.ViewModels
-{
- public class SushiViewModel : ISushiModel
- {
- public int Id { get; set; }
- [DisplayName("Название изделия")]
- public string SushiName { get; set; } = string.Empty;
- [DisplayName("Цена")]
- public double Price { get; set; }
- public Dictionary SushiComponents
- {
- get;
- set;
- } = new();
-
- }
-}
diff --git a/SushiBar/SushiBarDataModels — копия/Enums/OrderStatus.cs b/SushiBar/SushiBarDataModels — копия/Enums/OrderStatus.cs
new file mode 100644
index 0000000..c1b6d91
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/SushiBar/SushiBarDataModels — копия/IId.cs b/SushiBar/SushiBarDataModels — копия/IId.cs
new file mode 100644
index 0000000..91a1366
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/IId.cs
@@ -0,0 +1,7 @@
+namespace SushiBarDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBarDataModels — копия/Models/IComponentModel.cs b/SushiBar/SushiBarDataModels — копия/Models/IComponentModel.cs
new file mode 100644
index 0000000..b82c233
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/Models/IComponentModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+
+ }
+}
diff --git a/SushiBar/SushiBarDataModels — копия/Models/IOrderModel.cs b/SushiBar/SushiBarDataModels — копия/Models/IOrderModel.cs
new file mode 100644
index 0000000..02ca513
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using SushiBarDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int SushiId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels — копия/Models/ISushiModel.cs b/SushiBar/SushiBarDataModels — копия/Models/ISushiModel.cs
new file mode 100644
index 0000000..a6c7e0c
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/Models/ISushiModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarDataModels.Models
+{
+ public interface ISushiModel : IId
+ {
+ string SushiName { get; }
+ double Price { get; }
+ Dictionary SushiComponents { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels — копия/SushiBarDataModels.csproj b/SushiBar/SushiBarDataModels — копия/SushiBarDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/SushiBar/SushiBarDataModels — копия/SushiBarDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/SushiBar/SushiBarFileImplement — копия/DataFileSingleton.cs b/SushiBar/SushiBarFileImplement — копия/DataFileSingleton.cs
new file mode 100644
index 0000000..26bfc23
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/DataFileSingleton.cs
@@ -0,0 +1,58 @@
+using SushiBarFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SushiBarFileImplement
+{
+ internal class DataFileSingleton
+ {
+ private static DataFileSingleton? instance;
+ private readonly string ComponentFileName = "Component.xml";
+ private readonly string OrderFileName = "Order.xml";
+ private readonly string SushiFileName = "Sushi.xml";
+ public List Components { get; private set; }
+ public List Orders { get; private set; }
+ public List Sushis { get; private set; }
+
+ public static DataFileSingleton GetInstance()
+ {
+ if (instance == null)
+ {
+ instance = new DataFileSingleton();
+ }
+ return instance;
+ }
+
+ public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
+ public void SaveSushis() => SaveData(Sushis, SushiFileName, "Sushis", x => x.GetXElement);
+ public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
+
+ private DataFileSingleton()
+ {
+ Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
+ Sushis = LoadData(SushiFileName, "Sushi", x => Sushi.Create(x)!)!;
+ Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
+ }
+
+ private static List? LoadData(string filename, string xmlNodeName, Func selectFunction)
+ {
+ if (File.Exists(filename))
+ {
+ return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
+ }
+ return new List();
+ }
+
+ private static void SaveData(List data, string filename, string xmlNodeName, Func selectFunction)
+ {
+ if (data != null)
+ {
+ new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Implements/ComponentStorage.cs b/SushiBar/SushiBarFileImplement — копия/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..c413598
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Implements/ComponentStorage.cs
@@ -0,0 +1,86 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarFileImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataFileSingleton source;
+
+ public ComponentStorage()
+ {
+ source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ return source.Components.Select(x => x.GetViewModel).ToList();
+ }
+
+ public List GetFilteredList(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ return new();
+ }
+ return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public ComponentViewModel? GetElement(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ return source.Components.FirstOrDefault(x =>
+ (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
+ (model.Id.HasValue && x.Id == model.Id))
+ ?.GetViewModel;
+ }
+
+ public ComponentViewModel? Insert(ComponentBindingModel model)
+ {
+ model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1;
+ var newComponent = Component.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ source.Components.Add(newComponent);
+ source.SaveComponents();
+ return newComponent.GetViewModel;
+ }
+
+ public ComponentViewModel? Update(ComponentBindingModel model)
+ {
+ var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
+ if (component == null)
+ {
+ return null;
+ }
+ component.Update(model);
+ source.SaveComponents();
+ return component.GetViewModel;
+ }
+
+ public ComponentViewModel? Delete(ComponentBindingModel model)
+ {
+ var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
+ if (element != null)
+ {
+ source.Components.Remove(element);
+ source.SaveComponents();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Implements/OrderStorage.cs b/SushiBar/SushiBarFileImplement — копия/Implements/OrderStorage.cs
new file mode 100644
index 0000000..1664507
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Implements/OrderStorage.cs
@@ -0,0 +1,94 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarFileImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataFileSingleton source;
+
+ public OrderStorage()
+ {
+ source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList() => source.Orders.Select(x => AttachSushiName(x.GetViewModel)).ToList();
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return new();
+ }
+ return source.Orders.Where(x => x.Id == model.Id).Select(x => AttachSushiName(x.GetViewModel)).ToList();
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return new();
+ }
+ return AttachSushiName(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ source.Orders.Add(newOrder);
+ source.SaveOrders();
+ return AttachSushiName(newOrder.GetViewModel);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
+ if (order == null)
+ {
+ return null;
+ }
+ order.Update(model);
+ source.SaveOrders();
+ return AttachSushiName(order.GetViewModel);
+ }
+
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
+ if (order != null)
+ {
+ source.Orders.Remove(order);
+ source.SaveOrders();
+ return AttachSushiName(order.GetViewModel);
+ }
+ return null;
+ }
+
+ private OrderViewModel? AttachSushiName(OrderViewModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ var sushi = source.Sushis.FirstOrDefault(x => x.Id == model.SushiId);
+ if (sushi != null)
+ {
+ model.SushiName = sushi.SushiName;
+ }
+ return model;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Implements/SushiStorage.cs b/SushiBar/SushiBarFileImplement — копия/Implements/SushiStorage.cs
new file mode 100644
index 0000000..ac04014
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Implements/SushiStorage.cs
@@ -0,0 +1,86 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarFileImplement.Implements
+{
+ public class SushiStorage : ISushiStorage
+ {
+ private readonly DataFileSingleton source;
+
+ public SushiStorage()
+ {
+ source = DataFileSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ return source.Sushis.Select(x => x.GetViewModel).ToList();
+ }
+
+ public List GetFilteredList(SushiSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.SushiName))
+ {
+ return new();
+ }
+ return source.Sushis.Where(x => x.SushiName.Contains(model.SushiName)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public SushiViewModel? GetElement(SushiSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.SushiName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ return source.Sushis.FirstOrDefault(x =>
+ (!string.IsNullOrEmpty(model.SushiName) && x.SushiName == model.SushiName) ||
+ (model.Id.HasValue && x.Id == model.Id))
+ ?.GetViewModel;
+ }
+
+ public SushiViewModel? Insert(SushiBindingModel model)
+ {
+ model.Id = source.Sushis.Count > 0 ? source.Sushis.Max(x => x.Id) + 1 : 1;
+ var newSushi = Sushi.Create(model);
+ if (newSushi == null)
+ {
+ return null;
+ }
+ source.Sushis.Add(newSushi);
+ source.SaveSushis();
+ return newSushi.GetViewModel;
+ }
+
+ public SushiViewModel? Update(SushiBindingModel model)
+ {
+ var Sushi = source.Sushis.FirstOrDefault(x => x.Id == model.Id);
+ if (Sushi == null)
+ {
+ return null;
+ }
+ Sushi.Update(model);
+ source.SaveSushis();
+ return Sushi.GetViewModel;
+ }
+
+ public SushiViewModel? Delete(SushiBindingModel model)
+ {
+ var Sushi = source.Sushis.FirstOrDefault(x => x.Id == model.Id);
+ if (Sushi != null)
+ {
+ source.Sushis.Remove(Sushi);
+ source.SaveSushis();
+ return Sushi.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Models/Component.cs b/SushiBar/SushiBarFileImplement — копия/Models/Component.cs
new file mode 100644
index 0000000..05caf5e
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Models/Component.cs
@@ -0,0 +1,70 @@
+
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SushiBarFileImplement.Models
+{
+ internal class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; set; }
+
+ public static Component? Create(ComponentBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+
+ public static Component? Create(XElement element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ ComponentName = element.Element("ComponentName")!.Value,
+ Cost = Convert.ToDouble(element.Element("Cost")!.Value)
+ };
+ }
+
+ public void Update(ComponentBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+
+ public XElement GetXElement => new("Component",
+ new XAttribute("Id", Id),
+ new XElement("ComponentName", ComponentName),
+ new XElement("Cost", Cost.ToString()));
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Models/Order.cs b/SushiBar/SushiBarFileImplement — копия/Models/Order.cs
new file mode 100644
index 0000000..a8a207d
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Models/Order.cs
@@ -0,0 +1,92 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Enums;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SushiBarFileImplement.Models
+{
+ internal class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int SushiId { get; private set; }
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+ public DateTime? DateImplement { get; private set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ SushiId = model.SushiId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+
+ public static Order? Create(XElement element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+ string dateImplement = element.Element("DateImplement")!.Value;
+ return new Order()
+ {
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
+ Count = Convert.ToInt32(element.Element("Count")!.Value),
+ Sum = Convert.ToDouble(element.Element("Sum")!.Value),
+ Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
+ DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
+ DateImplement = (dateImplement == "" || dateImplement is null) ? Convert.ToDateTime(null) : Convert.ToDateTime(dateImplement)
+ };
+
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SushiId = SushiId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ };
+
+ public XElement GetXElement => new("Order",
+ new XAttribute("Id", Id),
+ new XElement("SushiId", SushiId.ToString()),
+ new XElement("Count", Count.ToString()),
+ new XElement("Sum", Sum.ToString()),
+ new XElement("Status", Status.ToString()),
+ new XElement("DateCreate", DateCreate.ToString()),
+ new XElement("DateImplement", DateImplement.ToString()));
+ }
+}
diff --git a/SushiBar/SushiBarFileImplement — копия/Models/Sushi.cs b/SushiBar/SushiBarFileImplement — копия/Models/Sushi.cs
new file mode 100644
index 0000000..8396f75
--- /dev/null
+++ b/SushiBar/SushiBarFileImplement — копия/Models/Sushi.cs
@@ -0,0 +1,86 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SushiBarFileImplement.Models
+{
+ public class Sushi : ISushiModel
+ {
+ public int Id { get; private set; }
+ public string SushiName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary Components { get; private set; } = new();
+ private Dictionary? _SushiComponents = null;
+ public Dictionary SushiComponents
+ {
+ get
+ {
+ if (_SushiComponents == null)
+ {
+ var source = DataFileSingleton.GetInstance();
+ _SushiComponents = Components.ToDictionary(x => x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
+ }
+ return _SushiComponents;
+ }
+ }
+ public static Sushi? Create(SushiBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Sushi()
+ {
+ Id = model.Id,
+ SushiName = model.SushiName,
+ Price = model.Price,
+ Components = model.SushiComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
+ };
+ }
+ public static Sushi? Create(XElement element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+ return new Sushi()
+ {
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ SushiName = element.Element("SushiName")!.Value,
+ Price = Convert.ToDouble(element.Element("Price")!.Value),
+ Components = element.Element("SushiComponents")!.Elements("SushiComponent").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
+ x => Convert.ToInt32(x.Element("Value")?.Value))
+ };
+ }
+ public void Update(SushiBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ SushiName = model.SushiName;
+ Price = model.Price;
+ Components = model.SushiComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
+ _SushiComponents = null;
+ }
+ public SushiViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SushiName = SushiName,
+ Price = Price,
+ SushiComponents = SushiComponents
+ };
+ public XElement GetXElement => new("Sushi",
+ new XAttribute("Id", Id),
+ new XElement("SushiName", SushiName),
+ new XElement("Price", Price.ToString()),
+ new XElement("SushiComponents", Components.Select(
+ x => new XElement("SushiComponent", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()));
+ }
+}
diff --git a/SushiBar/SushiBarContracts/SushiBarContracts.csproj b/SushiBar/SushiBarFileImplement — копия/SushiBarFileImplement.csproj
similarity index 79%
rename from SushiBar/SushiBarContracts/SushiBarContracts.csproj
rename to SushiBar/SushiBarFileImplement — копия/SushiBarFileImplement.csproj
index a25f2c8..ec020c5 100644
--- a/SushiBar/SushiBarContracts/SushiBarContracts.csproj
+++ b/SushiBar/SushiBarFileImplement — копия/SushiBarFileImplement.csproj
@@ -7,6 +7,7 @@
+
diff --git a/SushiBar/SushiBarListImplement/App.config b/SushiBar/SushiBarListImplement/App.config
deleted file mode 100644
index 56efbc7..0000000
--- a/SushiBar/SushiBarListImplement/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj b/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj
deleted file mode 100644
index bbf9d38..0000000
--- a/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}
- Exe
- SushiBarListImplement
- SushiBarListImplement
- v4.7.2
- 512
- true
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
- {993e0787-3ad5-4743-8997-c828cd0cdc10}
- SushiBarContracts
-
-
- {76043de7-71bc-41e8-b4c0-ecfaddfbf55f}
- SushiBarDataModels
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarListImplement/DataListSingleton.cs b/SushiBar/SushiBarListImplement_ — копия/DataListSingleton.cs
similarity index 88%
rename from SushiBar/SushiBarListImplement/DataListSingleton.cs
rename to SushiBar/SushiBarListImplement_ — копия/DataListSingleton.cs
index f0f9a1b..6eabe76 100644
--- a/SushiBar/SushiBarListImplement/DataListSingleton.cs
+++ b/SushiBar/SushiBarListImplement_ — копия/DataListSingleton.cs
@@ -12,12 +12,12 @@ namespace SushiBarListImplement
private static DataListSingleton? _instance;
public List Components { get; set; }
public List Orders { get; set; }
- public List Products { get; set; }
+ public List Sushis { get; set; }
private DataListSingleton()
{
Components = new List();
Orders = new List();
- Products = new List();
+ Sushis = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/SushiBar/SushiBarListImplement/ComponentStorage.cs b/SushiBar/SushiBarListImplement_ — копия/Implements/ComponentStorage.cs
similarity index 98%
rename from SushiBar/SushiBarListImplement/ComponentStorage.cs
rename to SushiBar/SushiBarListImplement_ — копия/Implements/ComponentStorage.cs
index e06268f..9ce66c4 100644
--- a/SushiBar/SushiBarListImplement/ComponentStorage.cs
+++ b/SushiBar/SushiBarListImplement_ — копия/Implements/ComponentStorage.cs
@@ -11,7 +11,7 @@ using SushiBarListImplement.Models;
namespace SushiBarListImplement.Implements
{
- internal class ComponentStorage : IComponentStorage
+ public class ComponentStorage : IComponentStorage
{
private readonly DataListSingleton _source;
public ComponentStorage()
@@ -107,4 +107,4 @@ namespace SushiBarListImplement.Implements
}
}
-}
+
diff --git a/SushiBar/SushiBarListImplement_ — копия/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement_ — копия/Implements/OrderStorage.cs
new file mode 100644
index 0000000..957b9fa
--- /dev/null
+++ b/SushiBar/SushiBarListImplement_ — копия/Implements/OrderStorage.cs
@@ -0,0 +1,125 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(AttachSushiName(order.GetViewModel));
+ }
+ return result;
+ }
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (model == null || !model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(AttachSushiName(order.GetViewModel));
+ }
+ }
+ return result;
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return AttachSushiName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return AttachSushiName(newOrder.GetViewModel);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return AttachSushiName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return AttachSushiName(element.GetViewModel);
+ }
+ }
+ return null;
+ }
+
+ private OrderViewModel AttachSushiName(OrderViewModel model)
+ {
+ foreach (var sushi in _source.Sushis)
+ {
+ if (sushi.Id == model.SushiId)
+ {
+ model.SushiName = sushi.SushiName;
+ return model;
+ }
+ }
+ return model;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement_ — копия/Implements/SushiStorage.cs b/SushiBar/SushiBarListImplement_ — копия/Implements/SushiStorage.cs
new file mode 100644
index 0000000..005e5c7
--- /dev/null
+++ b/SushiBar/SushiBarListImplement_ — копия/Implements/SushiStorage.cs
@@ -0,0 +1,113 @@
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+using SushiBarListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarListImplement.Implements
+{
+ public class SushiStorage : ISushiStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public SushiStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var Sushis in _source.Sushis)
+ {
+ result.Add(Sushis.GetViewModel);
+ }
+ return result;
+ }
+
+ public List GetFilteredList(SushiSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.SushiName))
+ {
+ return result;
+ }
+ foreach (var Sushis in _source.Sushis)
+ {
+ if (Sushis.SushiName.Contains(model.SushiName))
+ {
+ result.Add(Sushis.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public SushiViewModel? GetElement(SushiSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.SushiName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var sushis in _source.Sushis)
+ {
+ if ((!string.IsNullOrEmpty(model.SushiName) && sushis.SushiName == model.SushiName) ||
+ (model.Id.HasValue && sushis.Id == model.Id))
+ {
+ return sushis.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public SushiViewModel? Insert(SushiBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var sushis in _source.Sushis)
+ {
+ if (model.Id <= sushis.Id)
+ {
+ model.Id = sushis.Id + 1;
+ }
+ }
+ var newSushis = Sushi.Create(model);
+ if (newSushis == null)
+ {
+ return null;
+ }
+ _source.Sushis.Add(newSushis);
+ return newSushis.GetViewModel;
+ }
+
+ public SushiViewModel? Update(SushiBindingModel model)
+ {
+ foreach (var sushis in _source.Sushis)
+ {
+ if (sushis.Id == model.Id)
+ {
+ sushis.Update(model);
+ return sushis.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public SushiViewModel? Delete(SushiBindingModel model)
+ {
+ for (int i = 0; i < _source.Sushis.Count; ++i)
+ {
+ if (_source.Sushis[i].Id == model.Id)
+ {
+ var element = _source.Sushis[i];
+ _source.Sushis.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Component.cs b/SushiBar/SushiBarListImplement_ — копия/Models/Component.cs
similarity index 87%
rename from SushiBar/SushiBarListImplement/Component.cs
rename to SushiBar/SushiBarListImplement_ — копия/Models/Component.cs
index 453d89c..ecebaf6 100644
--- a/SushiBar/SushiBarListImplement/Component.cs
+++ b/SushiBar/SushiBarListImplement_ — копия/Models/Component.cs
@@ -3,6 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using SushiBarContracts;
+using SushiBarDataModels;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
namespace SushiBarListImplement.Models
{
diff --git a/SushiBar/SushiBarListImplement_ — копия/Models/Order.cs b/SushiBar/SushiBarListImplement_ — копия/Models/Order.cs
new file mode 100644
index 0000000..f1d69d4
--- /dev/null
+++ b/SushiBar/SushiBarListImplement_ — копия/Models/Order.cs
@@ -0,0 +1,62 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Enums;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int SushiId { get; private set; }
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+ public DateTime? DateImplement { get; private set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ SushiId = model.SushiId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ };
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SushiId = SushiId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement,
+ };
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Sushi.cs b/SushiBar/SushiBarListImplement_ — копия/Models/Sushi.cs
similarity index 50%
rename from SushiBar/SushiBarListImplement/Sushi.cs
rename to SushiBar/SushiBarListImplement_ — копия/Models/Sushi.cs
index 133090b..6f6bce2 100644
--- a/SushiBar/SushiBarListImplement/Sushi.cs
+++ b/SushiBar/SushiBarListImplement_ — копия/Models/Sushi.cs
@@ -3,49 +3,52 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
namespace SushiBarListImplement.Models
{
- internal class Sushi : IProductModel
+ public class Sushi : ISushiModel
{
public int Id { get; private set; }
- public string ProductName { get; private set; } = string.Empty;
+ public string SushiName { get; private set; } = string.Empty;
public double Price { get; private set; }
- public Dictionary ProductComponents
+ public Dictionary SushiComponents
{
get;
private set;
} = new Dictionary();
- public static Product? Create(ProductBindingModel? model)
+ public static Sushi? Create(SushiBindingModel? model)
{
if (model == null)
{
return null;
}
- return new Product()
+ return new Sushi()
{
Id = model.Id,
- ProductName = model.ProductName,
+ SushiName = model.SushiName,
Price = model.Price,
- ProductComponents = model.ProductComponents
+ SushiComponents = model.SushiComponents
};
}
- public void Update(ProductBindingModel? model)
+ public void Update(SushiBindingModel? model)
{
if (model == null)
{
return;
}
- ProductName = model.ProductName;
+ SushiName = model.SushiName;
Price = model.Price;
- ProductComponents = model.ProductComponents;
+ SushiComponents = model.SushiComponents;
}
- public ProductViewModel GetViewModel => new()
+ public SushiViewModel GetViewModel => new()
{
Id = Id,
- ProductName = ProductName,
+ SushiName = SushiName,
Price = Price,
- ProductComponents = ProductComponents
+ SushiComponents = SushiComponents
};
}
diff --git a/SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj b/SushiBar/SushiBarListImplement_ — копия/SushiBarListImplement.csproj
similarity index 64%
rename from SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj
rename to SushiBar/SushiBarListImplement_ — копия/SushiBarListImplement.csproj
index 8d13c8d..ec020c5 100644
--- a/SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj
+++ b/SushiBar/SushiBarListImplement_ — копия/SushiBarListImplement.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -6,12 +6,9 @@
enable
-
-
-
-
+
diff --git a/SushiBar/SushiBarView/FormComponent.Designer.cs b/SushiBar/SushiBarView/FormComponent.Designer.cs
deleted file mode 100644
index e12b999..0000000
--- a/SushiBar/SushiBarView/FormComponent.Designer.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-namespace SushiBarView
-{
- partial class FormComponent
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.ButtonSave = new System.Windows.Forms.Button();
- this.ButtonCancel = new System.Windows.Forms.Button();
- this.labelName = new System.Windows.Forms.Label();
- this.labelCost = new System.Windows.Forms.Label();
- this.textBoxName = new System.Windows.Forms.TextBox();
- this.textBoxCost = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // ButtonSave
- //
- this.ButtonSave.Location = new System.Drawing.Point(174, 99);
- this.ButtonSave.Name = "ButtonSave";
- this.ButtonSave.Size = new System.Drawing.Size(87, 26);
- this.ButtonSave.TabIndex = 0;
- this.ButtonSave.Text = "Сохранить";
- this.ButtonSave.UseVisualStyleBackColor = true;
- this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // ButtonCancel
- //
- this.ButtonCancel.Location = new System.Drawing.Point(267, 99);
- this.ButtonCancel.Name = "ButtonCancel";
- this.ButtonCancel.Size = new System.Drawing.Size(87, 26);
- this.ButtonCancel.TabIndex = 1;
- this.ButtonCancel.Text = "Отмена";
- this.ButtonCancel.UseVisualStyleBackColor = true;
- //
- // labelName
- //
- this.labelName.AutoSize = true;
- this.labelName.Location = new System.Drawing.Point(12, 24);
- this.labelName.Name = "labelName";
- this.labelName.Size = new System.Drawing.Size(59, 15);
- this.labelName.TabIndex = 2;
- this.labelName.Text = "Название";
- //
- // labelCost
- //
- this.labelCost.AutoSize = true;
- this.labelCost.Location = new System.Drawing.Point(12, 65);
- this.labelCost.Name = "labelCost";
- this.labelCost.Size = new System.Drawing.Size(35, 15);
- this.labelCost.TabIndex = 3;
- this.labelCost.Text = "Цена";
- //
- // textBoxName
- //
- this.textBoxName.Location = new System.Drawing.Point(83, 21);
- this.textBoxName.Name = "textBoxName";
- this.textBoxName.Size = new System.Drawing.Size(262, 23);
- this.textBoxName.TabIndex = 4;
- //
- // textBoxCost
- //
- this.textBoxCost.Location = new System.Drawing.Point(83, 57);
- this.textBoxCost.Name = "textBoxCost";
- this.textBoxCost.Size = new System.Drawing.Size(262, 23);
- this.textBoxCost.TabIndex = 5;
- //
- // FormComponent
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(354, 131);
- this.Controls.Add(this.textBoxCost);
- this.Controls.Add(this.textBoxName);
- this.Controls.Add(this.labelCost);
- this.Controls.Add(this.labelName);
- this.Controls.Add(this.ButtonCancel);
- this.Controls.Add(this.ButtonSave);
- this.Name = "FormComponent";
- this.Text = "Компонент";
- this.Load += new System.EventHandler(this.FormComponent_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Button ButtonSave;
- private Button ButtonCancel;
- private Label labelName;
- private Label labelCost;
- private TextBox textBoxName;
- private TextBox textBoxCost;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormComponent.cs b/SushiBar/SushiBarView/FormComponent.cs
deleted file mode 100644
index dfacef0..0000000
--- a/SushiBar/SushiBarView/FormComponent.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-
-
-namespace SushiBarView
-{
- public partial class FormComponent : Form
- {
- private readonly ILogger _logger;
- private readonly IComponentLogic _logic;
- private int? _id;
- public int Id { set { _id = value; } }
- public FormComponent(ILogger logger, IComponentLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
-
- }
-
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxName.Text))
- {
- MessageBox.Show(" ", "",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation(" ");
- try
- {
- var model = new ComponentBindingModel
- {
- Id = _id ?? 0,
- ComponentName = textBoxName.Text,
- Cost = Convert.ToDouble(textBoxCost.Text)
- };
- var operationResult = _id.HasValue ? _logic.Update(model) :
- _logic.Create(model);
- if (!operationResult)
- {
- throw new Exception(" . .");
- }
- MessageBox.Show(" ", "",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
-
- }
-
- private void FormComponent_Load(object sender, EventArgs e)
- {
- if (_id.HasValue)
- {
- try
- {
- _logger.LogInformation(" ");
- var view = _logic.ReadElement(new ComponentSearchModel
- {
- Id = _id.Value
- });
- if (view != null)
- {
- textBoxName.Text = view.ComponentName;
- textBoxCost.Text = view.Cost.ToString();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormComponent.resx b/SushiBar/SushiBarView/FormComponent.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormComponent.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormComponents.Designer.cs b/SushiBar/SushiBarView/FormComponents.Designer.cs
deleted file mode 100644
index 27db7a7..0000000
--- a/SushiBar/SushiBarView/FormComponents.Designer.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-namespace SushiBarView
-{
- partial class FormComponents
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.ButtonUpd = new System.Windows.Forms.Button();
- this.ButtonDel = new System.Windows.Forms.Button();
- this.ButtonAdd = new System.Windows.Forms.Button();
- this.ButtonRef = new System.Windows.Forms.Button();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // ButtonUpd
- //
- this.ButtonUpd.Location = new System.Drawing.Point(499, 74);
- this.ButtonUpd.Name = "ButtonUpd";
- this.ButtonUpd.Size = new System.Drawing.Size(112, 35);
- this.ButtonUpd.TabIndex = 0;
- this.ButtonUpd.Text = "Изменить";
- this.ButtonUpd.UseVisualStyleBackColor = true;
- this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // ButtonDel
- //
- this.ButtonDel.Location = new System.Drawing.Point(499, 126);
- this.ButtonDel.Name = "ButtonDel";
- this.ButtonDel.Size = new System.Drawing.Size(112, 35);
- this.ButtonDel.TabIndex = 1;
- this.ButtonDel.Text = "Удалить";
- this.ButtonDel.UseVisualStyleBackColor = true;
- this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // ButtonAdd
- //
- this.ButtonAdd.Location = new System.Drawing.Point(499, 23);
- this.ButtonAdd.Name = "ButtonAdd";
- this.ButtonAdd.Size = new System.Drawing.Size(112, 35);
- this.ButtonAdd.TabIndex = 2;
- this.ButtonAdd.Text = "Добавить";
- this.ButtonAdd.UseVisualStyleBackColor = true;
- this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // ButtonRef
- //
- this.ButtonRef.Location = new System.Drawing.Point(499, 177);
- this.ButtonRef.Name = "ButtonRef";
- this.ButtonRef.Size = new System.Drawing.Size(112, 35);
- this.ButtonRef.TabIndex = 3;
- this.ButtonRef.Text = "Обновить";
- this.ButtonRef.UseVisualStyleBackColor = true;
- this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // dataGridView
- //
- this.dataGridView.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 12);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(454, 365);
- this.dataGridView.TabIndex = 4;
- //
- // FormComponents
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(623, 389);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.ButtonRef);
- this.Controls.Add(this.ButtonAdd);
- this.Controls.Add(this.ButtonDel);
- this.Controls.Add(this.ButtonUpd);
- this.Name = "FormComponents";
- this.Text = "FormComponents";
- this.Load += new System.EventHandler(this.FormComponents_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private Button ButtonUpd;
- private Button ButtonDel;
- private Button ButtonAdd;
- private Button ButtonRef;
- private DataGridView dataGridView;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormComponents.cs b/SushiBar/SushiBarView/FormComponents.cs
deleted file mode 100644
index 704c8e0..0000000
--- a/SushiBar/SushiBarView/FormComponents.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace SushiBarView
-{
- public partial class FormComponents : Form
- {
- public FormComponents()
- {
- InitializeComponent();
- }
- private readonly ILogger _logger;
- private readonly IComponentLogic _logic;
- public FormComponents(ILogger logger, IComponentLogic
- logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
-
- private void FormComponents_Load(object sender, EventArgs e)
- {
- LoadData();
- }
- private void LoadData()
- {
- try
- {
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].Visible = false;
- dataGridView.Columns["ComponentName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка компонентов");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки компонентов");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
-
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
- if (service is FormComponent form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
-
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormComponent));
- if (service is FormComponent form)
- {
- form.Id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- }
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Удаление компонента");
- try
- {
- if (!_logic.Delete(new ComponentBindingModel
- {
- Id = id
- }))
- {
- throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка удаления компонента");
- MessageBox.Show(ex.Message, "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
-
- }
-}
diff --git a/SushiBar/SushiBarView/FormComponents.resx b/SushiBar/SushiBarView/FormComponents.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormComponents.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormCreateOrder.Designer.cs b/SushiBar/SushiBarView/FormCreateOrder.Designer.cs
deleted file mode 100644
index fe9c140..0000000
--- a/SushiBar/SushiBarView/FormCreateOrder.Designer.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-namespace SushiBarView
-{
- partial class FormCreateOrder
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.textBoxCount = new System.Windows.Forms.TextBox();
- this.labelCost = new System.Windows.Forms.Label();
- this.labelName = new System.Windows.Forms.Label();
- this.textBoxSum = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.ButtonCancel = new System.Windows.Forms.Button();
- this.ButtonSave = new System.Windows.Forms.Button();
- this.comboBoxSushi = new System.Windows.Forms.ComboBox();
- this.SuspendLayout();
- //
- // textBoxCount
- //
- this.textBoxCount.Location = new System.Drawing.Point(83, 42);
- this.textBoxCount.Name = "textBoxCount";
- this.textBoxCount.Size = new System.Drawing.Size(262, 23);
- this.textBoxCount.TabIndex = 9;
- this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCost_TextChanged);
- //
- // labelCost
- //
- this.labelCost.AutoSize = true;
- this.labelCost.Location = new System.Drawing.Point(5, 45);
- this.labelCost.Name = "labelCost";
- this.labelCost.Size = new System.Drawing.Size(72, 15);
- this.labelCost.TabIndex = 7;
- this.labelCost.Text = "Количество";
- this.labelCost.Click += new System.EventHandler(this.labelCost_Click);
- //
- // labelName
- //
- this.labelName.AutoSize = true;
- this.labelName.Location = new System.Drawing.Point(5, 12);
- this.labelName.Name = "labelName";
- this.labelName.Size = new System.Drawing.Size(53, 15);
- this.labelName.TabIndex = 6;
- this.labelName.Text = "Изделие";
- //
- // textBoxSum
- //
- this.textBoxSum.Location = new System.Drawing.Point(83, 80);
- this.textBoxSum.Name = "textBoxSum";
- this.textBoxSum.Size = new System.Drawing.Size(262, 23);
- this.textBoxSum.TabIndex = 11;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(5, 83);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(45, 15);
- this.label1.TabIndex = 10;
- this.label1.Text = "Сумма";
- //
- // ButtonCancel
- //
- this.ButtonCancel.Location = new System.Drawing.Point(258, 120);
- this.ButtonCancel.Name = "ButtonCancel";
- this.ButtonCancel.Size = new System.Drawing.Size(87, 26);
- this.ButtonCancel.TabIndex = 13;
- this.ButtonCancel.Text = "Отмена";
- this.ButtonCancel.UseVisualStyleBackColor = true;
- this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // ButtonSave
- //
- this.ButtonSave.Location = new System.Drawing.Point(165, 120);
- this.ButtonSave.Name = "ButtonSave";
- this.ButtonSave.Size = new System.Drawing.Size(87, 26);
- this.ButtonSave.TabIndex = 12;
- this.ButtonSave.Text = "Сохранить";
- this.ButtonSave.UseVisualStyleBackColor = true;
- this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // comboBoxSushi
- //
- this.comboBoxSushi.FormattingEnabled = true;
- this.comboBoxSushi.Location = new System.Drawing.Point(83, 9);
- this.comboBoxSushi.Name = "comboBoxSushi";
- this.comboBoxSushi.Size = new System.Drawing.Size(262, 23);
- this.comboBoxSushi.TabIndex = 14;
- this.comboBoxSushi.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // FormCreateOrder
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(354, 158);
- this.Controls.Add(this.comboBoxSushi);
- this.Controls.Add(this.ButtonCancel);
- this.Controls.Add(this.ButtonSave);
- this.Controls.Add(this.textBoxSum);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBoxCount);
- this.Controls.Add(this.labelCost);
- this.Controls.Add(this.labelName);
- this.Name = "FormCreateOrder";
- this.Text = "FormCreateOrder";
- this.Load += new System.EventHandler(this.FormCreateOrder_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private TextBox textBoxCount;
- private Label labelCost;
- private Label labelName;
- private TextBox textBoxSum;
- private Label label1;
- private Button ButtonCancel;
- private Button ButtonSave;
- private ComboBox comboBoxSushi;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormCreateOrder.cs b/SushiBar/SushiBarView/FormCreateOrder.cs
deleted file mode 100644
index fd23448..0000000
--- a/SushiBar/SushiBarView/FormCreateOrder.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-using SushiBarContracts.ViewModels;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace SushiBarView
-{
- public partial class FormCreateOrder : Form
- {
- private readonly ILogger _logger;
- private readonly ISushiLogic _logicP;
- private readonly IOrderLogic _logicO;
- private List? _list;
- public FormCreateOrder()
- {
- InitializeComponent();
- }
- public FormCreateOrder(ILogger logger, ISushiLogic logicP, IOrderLogic logicO)
- {
- InitializeComponent();
- _logger = logger;
- _logicP = logicP;
- _logicO = logicO;
- }
- private void FormCreateOrder_Load(object sender, EventArgs e)
- {
- _logger.LogInformation("Загрузка изделий для заказа");
- _list = _logicP.ReadList(null);
- if (_list != null)
- {
- comboBoxSushi.DisplayMember = "SushiName";
- comboBoxSushi.ValueMember = "Id";
- comboBoxSushi.DataSource = _list;
- comboBoxSushi.SelectedItem = null;
- _logger.LogInformation("Загрузка суши для заказа");
- }
- }
- private void labelCost_Click(object sender, EventArgs e)
- {
-
- }
-
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxCount.Text))
- {
- MessageBox.Show("Заполните поле Количество", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (comboBoxSushi.SelectedValue == null)
- {
- MessageBox.Show("Выберите изделие", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation("Создание заказа");
- try
- {
- var operationResult = _logicO.CreateOrder(new OrderBindingModel
- {
- SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
- Count = Convert.ToInt32(textBoxCount.Text),
- Sum = Convert.ToDouble(textBoxSum.Text)
- });
- if (!operationResult)
- {
- throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
- }
- MessageBox.Show("Сохранение прошло успешно", "Сообщение",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка создания заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void CalcSum()
- {
- if (comboBoxSushi.SelectedValue != null &&
- !string.IsNullOrEmpty(textBoxCount.Text))
- {
- try
- {
- int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
- var sushi = _logicP.ReadElement(new SushiSearchModel
- {
- Id
- = id
- });
- int count = Convert.ToInt32(textBoxCount.Text);
- textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0),
- 2).ToString();
- _logger.LogInformation("Расчет суммы заказа");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка расчета суммы заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
-
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- CalcSum();
- }
-
- private void textBoxCost_TextChanged(object sender, EventArgs e)
- {
- CalcSum();
- }
-
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
-}
diff --git a/SushiBar/SushiBarView/FormCreateOrder.resx b/SushiBar/SushiBarView/FormCreateOrder.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormCreateOrder.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormMain.Designer.cs b/SushiBar/SushiBarView/FormMain.Designer.cs
deleted file mode 100644
index 0c2348d..0000000
--- a/SushiBar/SushiBarView/FormMain.Designer.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-namespace SushiBarView
-{
- partial class FormMain
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.ButtonCreateOrder = new System.Windows.Forms.Button();
- this.ButtonOrderReady = new System.Windows.Forms.Button();
- this.ButtonRef = new System.Windows.Forms.Button();
- this.ButtonIssuedOrder = new System.Windows.Forms.Button();
- this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
- this.menuStrip = new System.Windows.Forms.MenuStrip();
- this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
- this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.menuStrip.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // ButtonCreateOrder
- //
- this.ButtonCreateOrder.Location = new System.Drawing.Point(676, 37);
- this.ButtonCreateOrder.Name = "ButtonCreateOrder";
- this.ButtonCreateOrder.Size = new System.Drawing.Size(217, 29);
- this.ButtonCreateOrder.TabIndex = 0;
- this.ButtonCreateOrder.Text = "Создать заказ";
- this.ButtonCreateOrder.UseVisualStyleBackColor = true;
- this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
- //
- // ButtonOrderReady
- //
- this.ButtonOrderReady.Location = new System.Drawing.Point(676, 180);
- this.ButtonOrderReady.Name = "ButtonOrderReady";
- this.ButtonOrderReady.Size = new System.Drawing.Size(217, 29);
- this.ButtonOrderReady.TabIndex = 1;
- this.ButtonOrderReady.Text = "Заказ готов";
- this.ButtonOrderReady.UseVisualStyleBackColor = true;
- this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
- //
- // ButtonRef
- //
- this.ButtonRef.Location = new System.Drawing.Point(676, 323);
- this.ButtonRef.Name = "ButtonRef";
- this.ButtonRef.Size = new System.Drawing.Size(217, 29);
- this.ButtonRef.TabIndex = 2;
- this.ButtonRef.Text = "Обновить список";
- this.ButtonRef.UseVisualStyleBackColor = true;
- this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // ButtonIssuedOrder
- //
- this.ButtonIssuedOrder.Location = new System.Drawing.Point(676, 256);
- this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
- this.ButtonIssuedOrder.Size = new System.Drawing.Size(217, 29);
- this.ButtonIssuedOrder.TabIndex = 3;
- this.ButtonIssuedOrder.Text = "Заказ выполнен";
- this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
- this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
- //
- // ButtonTakeOrderInWork
- //
- this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(676, 109);
- this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
- this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(217, 29);
- this.ButtonTakeOrderInWork.TabIndex = 4;
- this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
- this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
- this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
- //
- // menuStrip
- //
- this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripMenuItem1});
- this.menuStrip.Location = new System.Drawing.Point(0, 0);
- this.menuStrip.Name = "menuStrip";
- this.menuStrip.Size = new System.Drawing.Size(922, 24);
- this.menuStrip.TabIndex = 5;
- this.menuStrip.Text = "menuStrip1";
- //
- // toolStripMenuItem1
- //
- this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.componentsToolStripMenuItemToolStripMenuItem,
- this.sushiToolStripMenuItemToolStripMenuItem});
- this.toolStripMenuItem1.Name = "toolStripMenuItem1";
- this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20);
- this.toolStripMenuItem1.Text = "Справочники";
- //
- // componentsToolStripMenuItemToolStripMenuItem
- //
- this.componentsToolStripMenuItemToolStripMenuItem.Name = "componentsToolStripMenuItemToolStripMenuItem";
- this.componentsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.componentsToolStripMenuItemToolStripMenuItem.Text = "Компоненты";
- this.componentsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click);
- //
- // sushiToolStripMenuItemToolStripMenuItem
- //
- this.sushiToolStripMenuItemToolStripMenuItem.Name = "sushiToolStripMenuItemToolStripMenuItem";
- this.sushiToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.sushiToolStripMenuItemToolStripMenuItem.Text = "Суши";
- this.sushiToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.sushiToolStripMenuItem_Click);
- //
- // dataGridView
- //
- this.dataGridView.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 27);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(647, 344);
- this.dataGridView.TabIndex = 6;
- //
- // FormMain
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(922, 383);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.ButtonTakeOrderInWork);
- this.Controls.Add(this.ButtonIssuedOrder);
- this.Controls.Add(this.ButtonRef);
- this.Controls.Add(this.ButtonOrderReady);
- this.Controls.Add(this.ButtonCreateOrder);
- this.Controls.Add(this.menuStrip);
- this.MainMenuStrip = this.menuStrip;
- this.Name = "FormMain";
- this.Text = "FormMain";
- this.Load += new System.EventHandler(this.FormMain_Load);
- this.menuStrip.ResumeLayout(false);
- this.menuStrip.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Button ButtonCreateOrder;
- private Button ButtonOrderReady;
- private Button ButtonRef;
- private Button ButtonIssuedOrder;
- private Button ButtonTakeOrderInWork;
- private MenuStrip menuStrip;
- private ToolStripMenuItem toolStripMenuItem1;
- private ToolStripMenuItem componentsToolStripMenuItemToolStripMenuItem;
- private ToolStripMenuItem sushiToolStripMenuItemToolStripMenuItem;
- private DataGridView dataGridView;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormMain.cs b/SushiBar/SushiBarView/FormMain.cs
deleted file mode 100644
index 0ca85b9..0000000
--- a/SushiBar/SushiBarView/FormMain.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace SushiBarView
-{
- public partial class FormMain : Form
- {
- public FormMain()
- {
- InitializeComponent();
- }
-
- private void ButtonCreateOrder_Click(object sender, EventArgs e)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
- if (service is FormCreateOrder form)
- {
- form.ShowDialog();
- LoadData();
- }
- }
-
- private readonly ILogger _logger;
- private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
- {
- InitializeComponent();
- _logger = logger;
- _orderLogic = orderLogic;
- }
- private void FormMain_Load(object sender, EventArgs e)
- {
- LoadData();
- }
- private void LoadData()
- {
- _logger.LogInformation("Загрузка заказов");
- try
- {
- var list = _orderLogic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["SushiId"].Visible = false;
- dataGridView.Columns["SushiName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка заказов");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки заказов");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void componentsToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
- if (service is FormComponents form)
- {
- form.ShowDialog();
- }
- }
- private void sushiToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormSushis));
- if (service is FormSushis form)
- {
- form.ShowDialog();
- }
- }
-
- private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
- try
- {
- var operationResult = _orderLogic.TakeOrderInWork(new
- OrderBindingModel
- { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка передачи заказа в работу");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonOrderReady_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
- id);
- try
- {
- var operationResult = _orderLogic.FinishOrder(new
- OrderBindingModel
- { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о готовности заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
-MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonIssuedOrder_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
- id);
- try
- {
- var operationResult = _orderLogic.DeliveryOrder(new
- OrderBindingModel
- { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- _logger.LogInformation("Заказ №{id} выдан", id);
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
-
- }
-}
diff --git a/SushiBar/SushiBarView/FormMain.resx b/SushiBar/SushiBarView/FormMain.resx
deleted file mode 100644
index 81a9e3d..0000000
--- a/SushiBar/SushiBarView/FormMain.resx
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushi.Designer.cs b/SushiBar/SushiBarView/FormSushi.Designer.cs
deleted file mode 100644
index 3f53aec..0000000
--- a/SushiBar/SushiBarView/FormSushi.Designer.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-namespace SushiBarView
-{
- partial class FormSushi
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.textBoxPrice = new System.Windows.Forms.TextBox();
- this.textBoxName = new System.Windows.Forms.TextBox();
- this.labelCost = new System.Windows.Forms.Label();
- this.labelName = new System.Windows.Forms.Label();
- this.panel1 = new System.Windows.Forms.Panel();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.ButtonRef = new System.Windows.Forms.Button();
- this.ButtonAdd = new System.Windows.Forms.Button();
- this.ButtonDel = new System.Windows.Forms.Button();
- this.ButtonUpd = new System.Windows.Forms.Button();
- this.ButtonCancel = new System.Windows.Forms.Button();
- this.ButtonSave = new System.Windows.Forms.Button();
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // textBoxPrice
- //
- this.textBoxPrice.Location = new System.Drawing.Point(84, 48);
- this.textBoxPrice.Name = "textBoxPrice";
- this.textBoxPrice.Size = new System.Drawing.Size(262, 23);
- this.textBoxPrice.TabIndex = 9;
- //
- // textBoxName
- //
- this.textBoxName.Location = new System.Drawing.Point(84, 12);
- this.textBoxName.Name = "textBoxName";
- this.textBoxName.Size = new System.Drawing.Size(262, 23);
- this.textBoxName.TabIndex = 8;
- //
- // labelCost
- //
- this.labelCost.AutoSize = true;
- this.labelCost.Location = new System.Drawing.Point(13, 56);
- this.labelCost.Name = "labelCost";
- this.labelCost.Size = new System.Drawing.Size(35, 15);
- this.labelCost.TabIndex = 7;
- this.labelCost.Text = "Цена";
- //
- // labelName
- //
- this.labelName.AutoSize = true;
- this.labelName.Location = new System.Drawing.Point(13, 15);
- this.labelName.Name = "labelName";
- this.labelName.Size = new System.Drawing.Size(59, 15);
- this.labelName.TabIndex = 6;
- this.labelName.Text = "Название";
- //
- // panel1
- //
- this.panel1.Controls.Add(this.dataGridView);
- this.panel1.Controls.Add(this.ButtonRef);
- this.panel1.Controls.Add(this.ButtonAdd);
- this.panel1.Controls.Add(this.ButtonDel);
- this.panel1.Controls.Add(this.ButtonUpd);
- this.panel1.Location = new System.Drawing.Point(13, 100);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(725, 282);
- this.panel1.TabIndex = 10;
- //
- // dataGridView
- //
- this.dataGridView.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(18, 13);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(566, 255);
- this.dataGridView.TabIndex = 8;
- //
- // ButtonRef
- //
- this.ButtonRef.Location = new System.Drawing.Point(598, 198);
- this.ButtonRef.Name = "ButtonRef";
- this.ButtonRef.Size = new System.Drawing.Size(112, 35);
- this.ButtonRef.TabIndex = 7;
- this.ButtonRef.Text = "Обновить";
- this.ButtonRef.UseVisualStyleBackColor = true;
- this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // ButtonAdd
- //
- this.ButtonAdd.Location = new System.Drawing.Point(598, 44);
- this.ButtonAdd.Name = "ButtonAdd";
- this.ButtonAdd.Size = new System.Drawing.Size(112, 35);
- this.ButtonAdd.TabIndex = 6;
- this.ButtonAdd.Text = "Добавить";
- this.ButtonAdd.UseVisualStyleBackColor = true;
- this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // ButtonDel
- //
- this.ButtonDel.Location = new System.Drawing.Point(598, 147);
- this.ButtonDel.Name = "ButtonDel";
- this.ButtonDel.Size = new System.Drawing.Size(112, 35);
- this.ButtonDel.TabIndex = 5;
- this.ButtonDel.Text = "Удалить";
- this.ButtonDel.UseVisualStyleBackColor = true;
- this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // ButtonUpd
- //
- this.ButtonUpd.Location = new System.Drawing.Point(598, 95);
- this.ButtonUpd.Name = "ButtonUpd";
- this.ButtonUpd.Size = new System.Drawing.Size(112, 35);
- this.ButtonUpd.TabIndex = 4;
- this.ButtonUpd.Text = "Изменить";
- this.ButtonUpd.UseVisualStyleBackColor = true;
- this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // ButtonCancel
- //
- this.ButtonCancel.Location = new System.Drawing.Point(651, 412);
- this.ButtonCancel.Name = "ButtonCancel";
- this.ButtonCancel.Size = new System.Drawing.Size(87, 26);
- this.ButtonCancel.TabIndex = 12;
- this.ButtonCancel.Text = "Отмена";
- this.ButtonCancel.UseVisualStyleBackColor = true;
- this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // ButtonSave
- //
- this.ButtonSave.Location = new System.Drawing.Point(558, 412);
- this.ButtonSave.Name = "ButtonSave";
- this.ButtonSave.Size = new System.Drawing.Size(87, 26);
- this.ButtonSave.TabIndex = 11;
- this.ButtonSave.Text = "Сохранить";
- this.ButtonSave.UseVisualStyleBackColor = true;
- this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // FormSushi
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(750, 450);
- this.Controls.Add(this.ButtonCancel);
- this.Controls.Add(this.ButtonSave);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.textBoxPrice);
- this.Controls.Add(this.textBoxName);
- this.Controls.Add(this.labelCost);
- this.Controls.Add(this.labelName);
- this.Name = "FormSushi";
- this.Text = "FormSushi";
- this.Load += new System.EventHandler(this.FormSushi_Load);
- this.panel1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private TextBox textBoxPrice;
- private TextBox textBoxName;
- private Label labelCost;
- private Label labelName;
- private Panel panel1;
- private Button ButtonRef;
- private Button ButtonAdd;
- private Button ButtonDel;
- private Button ButtonUpd;
- private DataGridView dataGridView;
- private Button ButtonCancel;
- private Button ButtonSave;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushi.cs b/SushiBar/SushiBarView/FormSushi.cs
deleted file mode 100644
index b265edb..0000000
--- a/SushiBar/SushiBarView/FormSushi.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-using Microsoft.Extensions.Logging;
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.SearchModels;
-
-
-namespace SushiBarView
-{
- public partial class FormSushi : Form
- {
- private readonly ILogger _logger;
- private readonly ISushiLogic _logic;
- private int? _id;
- private Dictionary _sushiComponents;
- public int Id { set { _id = value; } }
-
- public FormSushi()
- {
- InitializeComponent();
- }
- public FormSushi(ILogger logger, ISushiLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- _sushiComponents = new Dictionary();
- }
-
- private void FormSushi_Load(object sender, EventArgs e)
- {
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.AllowUserToAddRows = false;
- DataGridViewTextBoxColumn Id = new DataGridViewTextBoxColumn();
- DataGridViewTextBoxColumn Component = new DataGridViewTextBoxColumn();
- DataGridViewTextBoxColumn Number = new DataGridViewTextBoxColumn();
- Component.HeaderText = "Количество";
- Number.HeaderText = "Компонент";
- Number.Name = "Number";
- Id.Name = "Id";
- dataGridView.Columns.Add(Id);
- dataGridView.Columns.Add(Number);
- dataGridView.Columns.Add(Component);
- dataGridView.Columns["Id"].Visible = false;
-
- dataGridView.Columns["Number"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- }
- if (_id.HasValue)
- {
- _logger.LogInformation("Загрузка суши");
- try
- {
- var view = _logic.ReadElement(new SushiSearchModel
- {
- Id = _id.Value
- });
- if (view != null)
- {
- textBoxName.Text = view.SushiName;
- textBoxPrice.Text = view.Price.ToString();
- _sushiComponents = view.SushiComponents ?? new
- Dictionary();
- LoadData();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void LoadData()
- {
- _logger.LogInformation("Загрузка компонент изделия");
- try
- {
- if (_sushiComponents != null)
- {
- dataGridView.Rows.Clear();
- foreach (var pc in _sushiComponents)
- {
- dataGridView.Rows.Add(new object[] { pc.Key,
-pc.Value.Item1.ComponentName, pc.Value.Item2 });
- }
- textBoxPrice.Text = CalcPrice().ToString();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки компонент изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
-
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
- if (service is FormSushiComponent form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (form.ComponentModel == null)
- {
- return;
- }
- _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
- if (_sushiComponents.ContainsKey(form.Id))
- {
- _sushiComponents[form.Id] = (form.ComponentModel, form.Count);
- }
- else
- {
- _sushiComponents.Add(form.Id, (form.ComponentModel, form.Count));
- }
- LoadData();
- }
- }
- }
-
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
- if (service is FormSushiComponent form)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
- form.Id = id;
- form.Count = _sushiComponents[id].Item2;
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (form.ComponentModel == null)
- {
- return;
- }
- _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
- _sushiComponents[form.Id] = (form.ComponentModel, form.Count);
- LoadData();
- }
- }
- }
- }
-
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
- _sushiComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- LoadData();
- }
- }
- }
-
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
-
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxName.Text))
- {
- MessageBox.Show("Заполните название", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (string.IsNullOrEmpty(textBoxPrice.Text))
- {
- MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- return;
- }
- if (_sushiComponents == null || _sushiComponents.Count == 0)
- {
- MessageBox.Show("Заполните компоненты", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation("Сохранение изделия");
- try
- {
- var model = new SushiBindingModel
- {
- Id = _id ?? 0,
- SushiName = textBoxName.Text,
- Price = Convert.ToDouble(textBoxPrice.Text),
- SushiComponents = _sushiComponents
- };
- var operationResult = _id.HasValue ? _logic.Update(model) :
- _logic.Create(model);
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- MessageBox.Show("Сохранение прошло успешно", "Сообщение",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка сохранения изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- }
-
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
-
- private double CalcPrice()
- {
- double price = 0;
- foreach (var elem in _sushiComponents)
- {
- price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
- }
- return Math.Round(price * 1.1, 2);
- }
- }
-}
diff --git a/SushiBar/SushiBarView/FormSushi.resx b/SushiBar/SushiBarView/FormSushi.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormSushi.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushiComponent.Designer.cs b/SushiBar/SushiBarView/FormSushiComponent.Designer.cs
deleted file mode 100644
index 17b2956..0000000
--- a/SushiBar/SushiBarView/FormSushiComponent.Designer.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-namespace SushiBarView
-{
- partial class FormSushiComponent
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.textBoxCount = new System.Windows.Forms.TextBox();
- this.labelCost = new System.Windows.Forms.Label();
- this.labelName = new System.Windows.Forms.Label();
- this.ButtonCancel = new System.Windows.Forms.Button();
- this.ButtonSave = new System.Windows.Forms.Button();
- this.comboBoxComponent = new System.Windows.Forms.ComboBox();
- this.SuspendLayout();
- //
- // textBoxCount
- //
- this.textBoxCount.Location = new System.Drawing.Point(87, 54);
- this.textBoxCount.Name = "textBoxCount";
- this.textBoxCount.Size = new System.Drawing.Size(262, 23);
- this.textBoxCount.TabIndex = 11;
- //
- // labelCost
- //
- this.labelCost.AutoSize = true;
- this.labelCost.Location = new System.Drawing.Point(12, 57);
- this.labelCost.Name = "labelCost";
- this.labelCost.Size = new System.Drawing.Size(72, 15);
- this.labelCost.TabIndex = 9;
- this.labelCost.Text = "Количество";
- //
- // labelName
- //
- this.labelName.AutoSize = true;
- this.labelName.Location = new System.Drawing.Point(12, 24);
- this.labelName.Name = "labelName";
- this.labelName.Size = new System.Drawing.Size(69, 15);
- this.labelName.TabIndex = 8;
- this.labelName.Text = "Компонент";
- //
- // ButtonCancel
- //
- this.ButtonCancel.Location = new System.Drawing.Point(271, 96);
- this.ButtonCancel.Name = "ButtonCancel";
- this.ButtonCancel.Size = new System.Drawing.Size(87, 26);
- this.ButtonCancel.TabIndex = 7;
- this.ButtonCancel.Text = "Отмена";
- this.ButtonCancel.UseVisualStyleBackColor = true;
- this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // ButtonSave
- //
- this.ButtonSave.Location = new System.Drawing.Point(178, 96);
- this.ButtonSave.Name = "ButtonSave";
- this.ButtonSave.Size = new System.Drawing.Size(87, 26);
- this.ButtonSave.TabIndex = 6;
- this.ButtonSave.Text = "Сохранить";
- this.ButtonSave.UseVisualStyleBackColor = true;
- this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // comboBoxComponent
- //
- this.comboBoxComponent.FormattingEnabled = true;
- this.comboBoxComponent.Location = new System.Drawing.Point(87, 21);
- this.comboBoxComponent.Name = "comboBoxComponent";
- this.comboBoxComponent.Size = new System.Drawing.Size(262, 23);
- this.comboBoxComponent.TabIndex = 12;
- //
- // FormSushiComponent
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(375, 141);
- this.Controls.Add(this.comboBoxComponent);
- this.Controls.Add(this.textBoxCount);
- this.Controls.Add(this.labelCost);
- this.Controls.Add(this.labelName);
- this.Controls.Add(this.ButtonCancel);
- this.Controls.Add(this.ButtonSave);
- this.Name = "FormSushiComponent";
- this.Text = "FormSushiComponent";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private TextBox textBoxCount;
- private Label labelCost;
- private Label labelName;
- private Button ButtonCancel;
- private Button ButtonSave;
- private ComboBox comboBoxComponent;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushiComponent.cs b/SushiBar/SushiBarView/FormSushiComponent.cs
deleted file mode 100644
index a7a020a..0000000
--- a/SushiBar/SushiBarView/FormSushiComponent.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using SushiBarContracts.BusinessLogicsContracts;
-using SushiBarContracts.ViewModels;
-using SushiBarDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace SushiBarView
-{
- public partial class FormSushiComponent : Form
- {
- private readonly List? _list;
- public int Id
- {
- get
- {
- return
- Convert.ToInt32(comboBoxComponent.SelectedValue);
- }
- set
- {
- comboBoxComponent.SelectedValue = value;
- }
- }
-
- public IComponentModel? ComponentModel
- {
- get
- {
- if (_list == null)
- {
- return null;
- }
- foreach (var elem in _list)
- {
- if (elem.Id == Id)
- {
- return elem;
- }
- }
- return null;
- }
- }
-
- public int Count
- {
- get { return Convert.ToInt32(textBoxCount.Text); }
- set
- { textBoxCount.Text = value.ToString(); }
- }
- public FormSushiComponent(IComponentLogic logic)
- {
- InitializeComponent();
- _list = logic.ReadList(null);
- if (_list != null)
- {
- comboBoxComponent.DisplayMember = "ComponentName";
- comboBoxComponent.ValueMember = "Id";
- comboBoxComponent.DataSource = _list;
- comboBoxComponent.SelectedItem = null;
- }
- }
- public FormSushiComponent()
- {
- InitializeComponent();
- }
-
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
-
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxCount.Text))
- {
- MessageBox.Show("Заполните поле Количество", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (comboBoxComponent.SelectedValue == null)
- {
- MessageBox.Show("Выберите компонент", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- DialogResult = DialogResult.OK;
- Close();
-
- }
- }
-}
diff --git a/SushiBar/SushiBarView/FormSushiComponent.resx b/SushiBar/SushiBarView/FormSushiComponent.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormSushiComponent.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushis.Designer.cs b/SushiBar/SushiBarView/FormSushis.Designer.cs
deleted file mode 100644
index 4cc40f2..0000000
--- a/SushiBar/SushiBarView/FormSushis.Designer.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-namespace SushiBarView
-{
- partial class FormSushis
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.ButtonRef = new System.Windows.Forms.Button();
- this.ButtonAdd = new System.Windows.Forms.Button();
- this.ButtonDel = new System.Windows.Forms.Button();
- this.ButtonUpd = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // dataGridView
- //
- this.dataGridView.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 12);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(454, 365);
- this.dataGridView.TabIndex = 9;
- //
- // ButtonRef
- //
- this.ButtonRef.Location = new System.Drawing.Point(499, 177);
- this.ButtonRef.Name = "ButtonRef";
- this.ButtonRef.Size = new System.Drawing.Size(112, 35);
- this.ButtonRef.TabIndex = 8;
- this.ButtonRef.Text = "Обновить";
- this.ButtonRef.UseVisualStyleBackColor = true;
- this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // ButtonAdd
- //
- this.ButtonAdd.Location = new System.Drawing.Point(499, 23);
- this.ButtonAdd.Name = "ButtonAdd";
- this.ButtonAdd.Size = new System.Drawing.Size(112, 35);
- this.ButtonAdd.TabIndex = 7;
- this.ButtonAdd.Text = "Добавить";
- this.ButtonAdd.UseVisualStyleBackColor = true;
- this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // ButtonDel
- //
- this.ButtonDel.Location = new System.Drawing.Point(499, 126);
- this.ButtonDel.Name = "ButtonDel";
- this.ButtonDel.Size = new System.Drawing.Size(112, 35);
- this.ButtonDel.TabIndex = 6;
- this.ButtonDel.Text = "Удалить";
- this.ButtonDel.UseVisualStyleBackColor = true;
- this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // ButtonUpd
- //
- this.ButtonUpd.Location = new System.Drawing.Point(499, 74);
- this.ButtonUpd.Name = "ButtonUpd";
- this.ButtonUpd.Size = new System.Drawing.Size(112, 35);
- this.ButtonUpd.TabIndex = 5;
- this.ButtonUpd.Text = "Изменить";
- this.ButtonUpd.UseVisualStyleBackColor = true;
- this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // FormSushis
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(637, 390);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.ButtonRef);
- this.Controls.Add(this.ButtonAdd);
- this.Controls.Add(this.ButtonDel);
- this.Controls.Add(this.ButtonUpd);
- this.Name = "FormSushis";
- this.Text = "FormSushis";
- this.Load += new System.EventHandler(this.FormSushi_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private DataGridView dataGridView;
- private Button ButtonRef;
- private Button ButtonAdd;
- private Button ButtonDel;
- private Button ButtonUpd;
- }
-}
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/FormSushis.cs b/SushiBar/SushiBarView/FormSushis.cs
deleted file mode 100644
index d5933eb..0000000
--- a/SushiBar/SushiBarView/FormSushis.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using SushiBarContracts.BindingModels;
-using SushiBarContracts.BusinessLogicsContracts;
-
-namespace SushiBarView
-{
- public partial class FormSushis : Form
- {
- public FormSushis()
- {
- InitializeComponent();
- }
-
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
- if (service is FormSushi form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
-
- private readonly ILogger _logger;
- private readonly ISushiLogic _logic;
-
- public FormSushis(ILogger logger, ISushiLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
-
- private void FormSushi_Load(object sender, EventArgs e)
- {
- LoadData();
- }
-
- private void LoadData()
- {
- try
- {
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].Visible = false;
- dataGridView.Columns["SushiComponents"].Visible = false;
- dataGridView.Columns["SushiName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка суши");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки суши");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
- if (service is FormSushi form)
- {
- form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- }
-
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Удаление пиццы");
- try
- {
- if (!_logic.Delete(new SushiBindingModel
- {
- Id = id
- }))
- {
- throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка удаления пиццы");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
-
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
- }
-}
diff --git a/SushiBar/SushiBarView/FormSushis.resx b/SushiBar/SushiBarView/FormSushis.resx
deleted file mode 100644
index f298a7b..0000000
--- a/SushiBar/SushiBarView/FormSushis.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/Program.cs b/SushiBar/SushiBarView/Program.cs
deleted file mode 100644
index 62a8d49..0000000
--- a/SushiBar/SushiBarView/Program.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using SushiBarContracts.BusinessLogicsContracts;
-using System;
-using SushiBarBusinessLogic.BusinessLogics;
-using SushiBarFileImplement.Implements;
-using SushiBarContracts.StoragesContracts;
-using SushiBarView;
-using NLog.Extensions.Logging;
-
-
-namespace SushiBarView
-{
- internal static class Program
- {
- private static ServiceProvider? _serviceProvider;
- public static ServiceProvider? ServiceProvider => _serviceProvider;
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- ApplicationConfiguration.Initialize();
- var services = new ServiceCollection();
- ConfigureServices(services);
- _serviceProvider = services.BuildServiceProvider();
- Application.Run(_serviceProvider.GetRequiredService());
- }
- private static void ConfigureServices(ServiceCollection services)
- {
- services.AddLogging(option =>
- {
- option.SetMinimumLevel(LogLevel.Information);
- option.AddNLog("nlog.config");
- });
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- 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/SushiBar/SushiBarView/SushiBarView.csproj b/SushiBar/SushiBarView/SushiBarView.csproj
deleted file mode 100644
index 574ede4..0000000
--- a/SushiBar/SushiBarView/SushiBarView.csproj
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
-
-
-
-
-
- Always
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SushiBar/SushiBarView/nlog.config b/SushiBar/SushiBarView/nlog.config
deleted file mode 100644
index 609afe6..0000000
--- a/SushiBar/SushiBarView/nlog.config
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file