From ae95a6a1bc2c132c9d2a780c9a9d5b229e2eb853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=9A=D1=80?= =?UTF-8?q?=D1=8E=D0=BA=D0=BE=D0=B2?= Date: Mon, 12 Feb 2024 12:46:44 +0400 Subject: [PATCH] lab1 done --- SnackBarBusinessLogic/ComponentLogic.cs | 115 +++++++++ SnackBarBusinessLogic/OrderLogic.cs | 124 ++++++++++ .../SnackBarBusinessLogic.csproj | 23 ++ SnackBarBusinessLogic/SnackLogic.cs | 114 +++++++++ .../BindingModels/ComponentBindingModel.cs | 16 ++ .../BindingModels/OrderBindingModel.cs | 21 ++ .../BindingModels/SnackBindingModel.cs | 17 ++ .../IComponentLogic.cs | 21 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 21 ++ .../BusinessLogicsContracts/ISnackLogic.cs | 20 ++ .../SearchModels/ComponentSearchModel.cs | 14 ++ .../SearchModels/OrderSearchModel.cs | 13 + .../SearchModels/SnackSearchModel.cs | 14 ++ SnackBarContracts/SnackBarContracts.csproj | 13 + .../StoragesContracts/IComponentStorage.cs | 21 ++ .../StoragesContracts/IOrderStorage.cs | 21 ++ .../StoragesContracts/ISnackStorage.cs | 21 ++ .../ViewModels/ComponentViewModel.cs | 19 ++ .../ViewModels/OrderViewModel.cs | 31 +++ .../ViewModels/SnackViewModel.cs | 21 ++ SnackBarDataModels/IComponentModel.cs | 14 ++ SnackBarDataModels/IId.cs | 13 + SnackBarDataModels/IOrderModel.cs | 18 ++ SnackBarDataModels/ISnackModel.cs | 16 ++ SnackBarDataModels/OrderStatus.cs | 11 + SnackBarDataModels/SnackBarDataModels.csproj | 9 + SnackBarListImplement/Component.cs | 47 ++++ SnackBarListImplement/ComponentStorage.cs | 106 ++++++++ SnackBarListImplement/DataListSingleton.cs | 31 +++ SnackBarListImplement/Order.cs | 73 ++++++ SnackBarListImplement/OrderStorage.cs | 122 +++++++++ SnackBarListImplement/Snack.cs | 51 ++++ .../SnackBarListImplement.csproj | 14 ++ SnackBarListImplement/SnackStorage.cs | 111 +++++++++ SnackBarView/Form1.Designer.cs | 39 --- SnackBarView/Form1.cs | 10 - SnackBarView/FormComponent.Designer.cs | 118 +++++++++ SnackBarView/FormComponent.cs | 84 +++++++ SnackBarView/FormComponent.resx | 120 +++++++++ SnackBarView/FormComponents.Designer.cs | 118 +++++++++ SnackBarView/FormComponents.cs | 109 ++++++++ SnackBarView/FormComponents.resx | 120 +++++++++ SnackBarView/FormCreateOrder.Designer.cs | 143 +++++++++++ SnackBarView/FormCreateOrder.cs | 120 +++++++++ SnackBarView/FormCreateOrder.resx | 120 +++++++++ SnackBarView/FormMain.Designer.cs | 174 +++++++++++++ SnackBarView/FormMain.cs | 170 +++++++++++++ SnackBarView/FormMain.resx | 123 +++++++++ SnackBarView/FormSnack.Designer.cs | 234 ++++++++++++++++++ SnackBarView/FormSnack.cs | 220 ++++++++++++++++ SnackBarView/FormSnack.resx | 129 ++++++++++ SnackBarView/FormSnackComponent.Designer.cs | 118 +++++++++ SnackBarView/FormSnackComponent.cs | 87 +++++++ SnackBarView/FormSnackComponent.resx | 120 +++++++++ SnackBarView/FormSnacks.Designer.cs | 115 +++++++++ SnackBarView/FormSnacks.cs | 113 +++++++++ SnackBarView/FormSnacks.resx | 120 +++++++++ SnackBarView/Program.cs | 38 ++- SnackBarView/Properties/Resources.Designer.cs | 63 +++++ .../{Form1.resx => Properties/Resources.resx} | 0 SnackBarView/SnackBarView.csproj | 14 ++ SnackBarView/SnackBarView.sln | 26 +- SnackBarView/nlog.config | 15 ++ 63 files changed, 4245 insertions(+), 51 deletions(-) create mode 100644 SnackBarBusinessLogic/ComponentLogic.cs create mode 100644 SnackBarBusinessLogic/OrderLogic.cs create mode 100644 SnackBarBusinessLogic/SnackBarBusinessLogic.csproj create mode 100644 SnackBarBusinessLogic/SnackLogic.cs create mode 100644 SnackBarContracts/BindingModels/ComponentBindingModel.cs create mode 100644 SnackBarContracts/BindingModels/OrderBindingModel.cs create mode 100644 SnackBarContracts/BindingModels/SnackBindingModel.cs create mode 100644 SnackBarContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 SnackBarContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 SnackBarContracts/BusinessLogicsContracts/ISnackLogic.cs create mode 100644 SnackBarContracts/SearchModels/ComponentSearchModel.cs create mode 100644 SnackBarContracts/SearchModels/OrderSearchModel.cs create mode 100644 SnackBarContracts/SearchModels/SnackSearchModel.cs create mode 100644 SnackBarContracts/SnackBarContracts.csproj create mode 100644 SnackBarContracts/StoragesContracts/IComponentStorage.cs create mode 100644 SnackBarContracts/StoragesContracts/IOrderStorage.cs create mode 100644 SnackBarContracts/StoragesContracts/ISnackStorage.cs create mode 100644 SnackBarContracts/ViewModels/ComponentViewModel.cs create mode 100644 SnackBarContracts/ViewModels/OrderViewModel.cs create mode 100644 SnackBarContracts/ViewModels/SnackViewModel.cs create mode 100644 SnackBarDataModels/IComponentModel.cs create mode 100644 SnackBarDataModels/IId.cs create mode 100644 SnackBarDataModels/IOrderModel.cs create mode 100644 SnackBarDataModels/ISnackModel.cs create mode 100644 SnackBarDataModels/OrderStatus.cs create mode 100644 SnackBarDataModels/SnackBarDataModels.csproj create mode 100644 SnackBarListImplement/Component.cs create mode 100644 SnackBarListImplement/ComponentStorage.cs create mode 100644 SnackBarListImplement/DataListSingleton.cs create mode 100644 SnackBarListImplement/Order.cs create mode 100644 SnackBarListImplement/OrderStorage.cs create mode 100644 SnackBarListImplement/Snack.cs create mode 100644 SnackBarListImplement/SnackBarListImplement.csproj create mode 100644 SnackBarListImplement/SnackStorage.cs delete mode 100644 SnackBarView/Form1.Designer.cs delete mode 100644 SnackBarView/Form1.cs create mode 100644 SnackBarView/FormComponent.Designer.cs create mode 100644 SnackBarView/FormComponent.cs create mode 100644 SnackBarView/FormComponent.resx create mode 100644 SnackBarView/FormComponents.Designer.cs create mode 100644 SnackBarView/FormComponents.cs create mode 100644 SnackBarView/FormComponents.resx create mode 100644 SnackBarView/FormCreateOrder.Designer.cs create mode 100644 SnackBarView/FormCreateOrder.cs create mode 100644 SnackBarView/FormCreateOrder.resx create mode 100644 SnackBarView/FormMain.Designer.cs create mode 100644 SnackBarView/FormMain.cs create mode 100644 SnackBarView/FormMain.resx create mode 100644 SnackBarView/FormSnack.Designer.cs create mode 100644 SnackBarView/FormSnack.cs create mode 100644 SnackBarView/FormSnack.resx create mode 100644 SnackBarView/FormSnackComponent.Designer.cs create mode 100644 SnackBarView/FormSnackComponent.cs create mode 100644 SnackBarView/FormSnackComponent.resx create mode 100644 SnackBarView/FormSnacks.Designer.cs create mode 100644 SnackBarView/FormSnacks.cs create mode 100644 SnackBarView/FormSnacks.resx create mode 100644 SnackBarView/Properties/Resources.Designer.cs rename SnackBarView/{Form1.resx => Properties/Resources.resx} (100%) create mode 100644 SnackBarView/nlog.config diff --git a/SnackBarBusinessLogic/ComponentLogic.cs b/SnackBarBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..58b5b71 --- /dev/null +++ b/SnackBarBusinessLogic/ComponentLogic.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using Microsoft.Extensions.Logging; + + + +namespace SnackBarBusinessLogic.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("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/SnackBarBusinessLogic/OrderLogic.cs b/SnackBarBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..36d73f5 --- /dev/null +++ b/SnackBarBusinessLogic/OrderLogic.cs @@ -0,0 +1,124 @@ +using SnackBarContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using SnackBarDataModels.Enums; +using Microsoft.Extensions.Logging; + +namespace SnackBarBusinessLogic.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. Id:{ 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 ChangeStatus(OrderBindingModel model, OrderStatus status) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + OrderStatus oldStatus = model.Status; + model.Status = status; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + model.Status = oldStatus; + _logger.LogWarning("Update 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.SnackId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор закусок", nameof(model.SnackId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество закусок в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count)); + } + _logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id); + } + } +} diff --git a/SnackBarBusinessLogic/SnackBarBusinessLogic.csproj b/SnackBarBusinessLogic/SnackBarBusinessLogic.csproj new file mode 100644 index 0000000..bbcd7e0 --- /dev/null +++ b/SnackBarBusinessLogic/SnackBarBusinessLogic.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + diff --git a/SnackBarBusinessLogic/SnackLogic.cs b/SnackBarBusinessLogic/SnackLogic.cs new file mode 100644 index 0000000..2362281 --- /dev/null +++ b/SnackBarBusinessLogic/SnackLogic.cs @@ -0,0 +1,114 @@ +using Microsoft.Extensions.Logging; +using SnackBarBusinessLogic.BusinessLogics; +using SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarBusinessLogic.BusinessLogics +{ + public class SnackLogic : ISnackLogic + { + private readonly ILogger _logger; + private readonly ISnackStorage _snackStorage; + public SnackLogic(ILogger logger, ISnackStorage snackStorage) + { + _logger = logger; + _snackStorage = snackStorage; + } + public List? ReadList(SnackSearchModel? model) + { + _logger.LogInformation("ReadList. SnackName:{SnackName}.Id:{ Id}", model?.SnackName, model?.Id); + var list = model == null ? _snackStorage.GetFullList() : _snackStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public SnackViewModel? ReadElement(SnackSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. SnackName:{SnackName}.Id:{ Id}", model.SnackName, model.Id); + var element = _snackStorage.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(SnackBindingModel model) + { + CheckModel(model); + if (_snackStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(SnackBindingModel model) + { + CheckModel(model); + if (_snackStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(SnackBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_snackStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(SnackBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.SnackName)) + { + throw new ArgumentNullException("Нет названия закуски", + nameof(model.SnackName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена закуски должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Snack. SnackName:{SnackName}.Price:{ Price}. Id: { Id}", model.SnackName, model.Price, model.Id); + var element = _snackStorage.GetElement(new SnackSearchModel + { + SnackName = model.SnackName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Закуска с таким названием уже есть"); + } + } + } +} diff --git a/SnackBarContracts/BindingModels/ComponentBindingModel.cs b/SnackBarContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..dc05487 --- /dev/null +++ b/SnackBarContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Models; + +namespace SnackBarContracts.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/SnackBarContracts/BindingModels/OrderBindingModel.cs b/SnackBarContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..f256bd5 --- /dev/null +++ b/SnackBarContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Enums; +using SnackBarDataModels.Models; + +namespace SnackBarContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int SnackId { 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/SnackBarContracts/BindingModels/SnackBindingModel.cs b/SnackBarContracts/BindingModels/SnackBindingModel.cs new file mode 100644 index 0000000..326f81a --- /dev/null +++ b/SnackBarContracts/BindingModels/SnackBindingModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Models; + +namespace SnackBarContracts.BindingModels +{ + public class SnackBindingModel : ISnackModel + { + public int Id { get; set; } + public string SnackName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary SnackComponents { get; set; } = new(); + } +} diff --git a/SnackBarContracts/BusinessLogicsContracts/IComponentLogic.cs b/SnackBarContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..e5f983d --- /dev/null +++ b/SnackBarContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; + + +namespace SnackBarContracts.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/SnackBarContracts/BusinessLogicsContracts/IOrderLogic.cs b/SnackBarContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..b0d1dd2 --- /dev/null +++ b/SnackBarContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; + + +namespace SnackBarContracts.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/SnackBarContracts/BusinessLogicsContracts/ISnackLogic.cs b/SnackBarContracts/BusinessLogicsContracts/ISnackLogic.cs new file mode 100644 index 0000000..01434b4 --- /dev/null +++ b/SnackBarContracts/BusinessLogicsContracts/ISnackLogic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; + +namespace SnackBarContracts.BusinessLogicsContracts +{ + public interface ISnackLogic + { + List? ReadList(SnackSearchModel? model); + SnackViewModel? ReadElement(SnackSearchModel model); + bool Create(SnackBindingModel model); + bool Update(SnackBindingModel model); + bool Delete(SnackBindingModel model); + } +} diff --git a/SnackBarContracts/SearchModels/ComponentSearchModel.cs b/SnackBarContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..b8a3651 --- /dev/null +++ b/SnackBarContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/SnackBarContracts/SearchModels/OrderSearchModel.cs b/SnackBarContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..7d66569 --- /dev/null +++ b/SnackBarContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/SnackBarContracts/SearchModels/SnackSearchModel.cs b/SnackBarContracts/SearchModels/SnackSearchModel.cs new file mode 100644 index 0000000..34c3d4d --- /dev/null +++ b/SnackBarContracts/SearchModels/SnackSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarContracts.SearchModels +{ + public class SnackSearchModel + { + public int? Id { get; set; } + public string? SnackName { get; set; } + } +} diff --git a/SnackBarContracts/SnackBarContracts.csproj b/SnackBarContracts/SnackBarContracts.csproj new file mode 100644 index 0000000..16c5379 --- /dev/null +++ b/SnackBarContracts/SnackBarContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/SnackBarContracts/StoragesContracts/IComponentStorage.cs b/SnackBarContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..b8cc57b --- /dev/null +++ b/SnackBarContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarContracts.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/SnackBarContracts/StoragesContracts/IOrderStorage.cs b/SnackBarContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..49835fc --- /dev/null +++ b/SnackBarContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,21 @@ +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarContracts.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/SnackBarContracts/StoragesContracts/ISnackStorage.cs b/SnackBarContracts/StoragesContracts/ISnackStorage.cs new file mode 100644 index 0000000..eefae9b --- /dev/null +++ b/SnackBarContracts/StoragesContracts/ISnackStorage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; + +namespace SnackBarContracts.StoragesContracts +{ + public interface ISnackStorage + { + List GetFullList(); + List GetFilteredList(SnackSearchModel model); + SnackViewModel? GetElement(SnackSearchModel model); + SnackViewModel? Insert(SnackBindingModel model); + SnackViewModel? Update(SnackBindingModel model); + SnackViewModel? Delete(SnackBindingModel model); + } +} diff --git a/SnackBarContracts/ViewModels/ComponentViewModel.cs b/SnackBarContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..0e77b73 --- /dev/null +++ b/SnackBarContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Models; +using System.ComponentModel; + +namespace SnackBarContracts.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/SnackBarContracts/ViewModels/OrderViewModel.cs b/SnackBarContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..f7afd13 --- /dev/null +++ b/SnackBarContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Enums; +using SnackBarDataModels.Models; +using System.ComponentModel; + + +namespace SnackBarContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int SnackId { get; set; } + [DisplayName("Изделие")] + public string SnackName { 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/SnackBarContracts/ViewModels/SnackViewModel.cs b/SnackBarContracts/ViewModels/SnackViewModel.cs new file mode 100644 index 0000000..e28dbf3 --- /dev/null +++ b/SnackBarContracts/ViewModels/SnackViewModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarDataModels.Models; +using System.ComponentModel; + +namespace SnackBarContracts.ViewModels +{ + public class SnackViewModel : ISnackModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string SnackName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary SnackComponents { get; set; } = new(); + + } +} diff --git a/SnackBarDataModels/IComponentModel.cs b/SnackBarDataModels/IComponentModel.cs new file mode 100644 index 0000000..581476f --- /dev/null +++ b/SnackBarDataModels/IComponentModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/SnackBarDataModels/IId.cs b/SnackBarDataModels/IId.cs new file mode 100644 index 0000000..94f5236 --- /dev/null +++ b/SnackBarDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/SnackBarDataModels/IOrderModel.cs b/SnackBarDataModels/IOrderModel.cs new file mode 100644 index 0000000..25fba96 --- /dev/null +++ b/SnackBarDataModels/IOrderModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarDataModels.Enums +{ + public interface IOrderModel : IId + { + int SnackId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/SnackBarDataModels/ISnackModel.cs b/SnackBarDataModels/ISnackModel.cs new file mode 100644 index 0000000..78e0e36 --- /dev/null +++ b/SnackBarDataModels/ISnackModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SnackBarDataModels.Models +{ + public interface ISnackModel : IId + { + string SnackName { get; } + double Price { get; } + Dictionary SnackComponents { get; } + + } +} diff --git a/SnackBarDataModels/OrderStatus.cs b/SnackBarDataModels/OrderStatus.cs new file mode 100644 index 0000000..3b879a0 --- /dev/null +++ b/SnackBarDataModels/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace SnackBarDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/SnackBarDataModels/SnackBarDataModels.csproj b/SnackBarDataModels/SnackBarDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/SnackBarDataModels/SnackBarDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/SnackBarListImplement/Component.cs b/SnackBarListImplement/Component.cs new file mode 100644 index 0000000..3e114c6 --- /dev/null +++ b/SnackBarListImplement/Component.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.ViewModels; +using SnackBarDataModels.Models; + +namespace SnackBarListImplement.Models +{ + public 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 void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + + } +} \ No newline at end of file diff --git a/SnackBarListImplement/ComponentStorage.cs b/SnackBarListImplement/ComponentStorage.cs new file mode 100644 index 0000000..e77f4c8 --- /dev/null +++ b/SnackBarListImplement/ComponentStorage.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using SnackBarListImplement.Models; + + +namespace SnackBarListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) || (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SnackBarListImplement/DataListSingleton.cs b/SnackBarListImplement/DataListSingleton.cs new file mode 100644 index 0000000..74bf139 --- /dev/null +++ b/SnackBarListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarListImplement.Models; + +namespace SnackBarListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Snacks { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Snacks = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/SnackBarListImplement/Order.cs b/SnackBarListImplement/Order.cs new file mode 100644 index 0000000..15f481a --- /dev/null +++ b/SnackBarListImplement/Order.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.ViewModels; +using SnackBarDataModels.Enums; +using SnackBarDataModels.Models; + +namespace SnackBarListImplement.Models +{ + public class Order : IOrderModel + { + public int SnackId { 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 int Id { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order + { + Id = model.Id, + SnackId = model.SnackId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Id = model.Id; + SnackId = model.SnackId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + SnackId = SnackId, + Count = Count, + Sum = Sum, + DateCreate = DateCreate, + DateImplement = DateImplement, + Id = Id, + Status = Status, + }; + } +} diff --git a/SnackBarListImplement/OrderStorage.cs b/SnackBarListImplement/OrderStorage.cs new file mode 100644 index 0000000..5a218cd --- /dev/null +++ b/SnackBarListImplement/OrderStorage.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using SnackBarListImplement.Models; + +namespace SnackBarListImplement.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(AddSnackName(order.GetViewModel)); + } + return result; + } + + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (!model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AddSnackName(order.GetViewModel)); + } + } + return result; + } + + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + return AddSnackName(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 AddSnackName(newOrder.GetViewModel); + } + + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return AddSnackName(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 AddSnackName(element.GetViewModel); + } + } + return null; + } + + private OrderViewModel AddSnackName(OrderViewModel model) + { + var selectedSnack = _source.Snacks.Find(snack => snack.Id == model.SnackId); + if (selectedSnack != null) + { + model.SnackName = selectedSnack.SnackName; + } + return model; + } + } +} diff --git a/SnackBarListImplement/Snack.cs b/SnackBarListImplement/Snack.cs new file mode 100644 index 0000000..a588419 --- /dev/null +++ b/SnackBarListImplement/Snack.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.ViewModels; +using SnackBarDataModels.Models; + + +namespace SnackBarListImplement.Models +{ + public class Snack : ISnackModel + { + public int Id { get; private set; } + public string SnackName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary SnackComponents { get; private set; } = new Dictionary(); + public static Snack? Create(SnackBindingModel? model) + { + if (model == null) + { + return null; + } + return new Snack() + { + Id = model.Id, + SnackName = model.SnackName, + Price = model.Price, + SnackComponents = model.SnackComponents + }; + } + public void Update(SnackBindingModel? model) + { + if (model == null) + { + return; + } + SnackName = model.SnackName; + Price = model.Price; + SnackComponents = model.SnackComponents; + } + public SnackViewModel GetViewModel => new() + { + Id = Id, + SnackName = SnackName, + Price = Price, + SnackComponents = SnackComponents + }; + } +} diff --git a/SnackBarListImplement/SnackBarListImplement.csproj b/SnackBarListImplement/SnackBarListImplement.csproj new file mode 100644 index 0000000..1297ced --- /dev/null +++ b/SnackBarListImplement/SnackBarListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/SnackBarListImplement/SnackStorage.cs b/SnackBarListImplement/SnackStorage.cs new file mode 100644 index 0000000..432dc46 --- /dev/null +++ b/SnackBarListImplement/SnackStorage.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.ConstrainedExecution; +using System.Text; +using System.Threading.Tasks; +using SnackBarContracts.BindingModels; +using SnackBarContracts.SearchModels; +using SnackBarContracts.StoragesContracts; +using SnackBarContracts.ViewModels; +using SnackBarListImplement.Models; + +namespace SnackBarListImplement.Implements +{ + public class SnackStorage : ISnackStorage + { + private readonly DataListSingleton _source; + + public SnackStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var snack in _source.Snacks) + { + result.Add(snack.GetViewModel); + } + return result; + } + + public List GetFilteredList(SnackSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SnackName)) + { + return result; + } + foreach (var snack in _source.Snacks) + { + if (snack.SnackName.Contains(model.SnackName)) + { + result.Add(snack.GetViewModel); + } + } + return result; + } + public SnackViewModel? GetElement(SnackSearchModel model) + { + if (string.IsNullOrEmpty(model.SnackName) && !model.Id.HasValue) + { + return null; + } + foreach (var snack in _source.Snacks) + { + if ((!string.IsNullOrEmpty(model.SnackName) && snack.SnackName == model.SnackName) || (model.Id.HasValue && snack.Id == model.Id)) + { + return snack.GetViewModel; + } + } + return null; + } + + public SnackViewModel? Insert(SnackBindingModel model) + { + model.Id = 1; + foreach (var snack in _source.Snacks) + { + if (model.Id <= snack.Id) + { + model.Id = snack.Id + 1; + } + } + var newSnack = Snack.Create(model); + if (newSnack == null) + { + return null; + } + _source.Snacks.Add(newSnack); + return newSnack.GetViewModel; + } + + public SnackViewModel? Update(SnackBindingModel model) + { + foreach (var snack in _source.Snacks) + { + if (snack.Id == model.Id) + { + snack.Update(model); + return snack.GetViewModel; + } + } + return null; + } + public SnackViewModel? Delete(SnackBindingModel model) + { + for (int i = 0; i < _source.Snacks.Count; ++i) + { + if (_source.Snacks[i].Id == model.Id) + { + var element = _source.Snacks[i]; + _source.Snacks.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SnackBarView/Form1.Designer.cs b/SnackBarView/Form1.Designer.cs deleted file mode 100644 index 93254d4..0000000 --- a/SnackBarView/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace SnackBarView -{ - partial class Form1 - { - /// - /// 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.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/SnackBarView/Form1.cs b/SnackBarView/Form1.cs deleted file mode 100644 index 9b06831..0000000 --- a/SnackBarView/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SnackBarView -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/SnackBarView/FormComponent.Designer.cs b/SnackBarView/FormComponent.Designer.cs new file mode 100644 index 0000000..5606096 --- /dev/null +++ b/SnackBarView/FormComponent.Designer.cs @@ -0,0 +1,118 @@ +namespace SnackBarView +{ + 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() + { + buttonSave = new Button(); + buttonCancel = new Button(); + labelComponentName = new Label(); + labelCostComponent = new Label(); + textBoxName = new TextBox(); + textBoxCost = new TextBox(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Location = new Point(205, 117); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 0; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(330, 117); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 1; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // labelComponentName + // + labelComponentName.AutoSize = true; + labelComponentName.Location = new Point(12, 30); + labelComponentName.Name = "labelComponentName"; + labelComponentName.Size = new Size(80, 20); + labelComponentName.TabIndex = 2; + labelComponentName.Text = "Название:"; + // + // labelCostComponent + // + labelCostComponent.AutoSize = true; + labelCostComponent.Location = new Point(12, 70); + labelCostComponent.Name = "labelCostComponent"; + labelCostComponent.Size = new Size(48, 20); + labelCostComponent.TabIndex = 3; + labelCostComponent.Text = "Цена:"; + // + // textBoxName + // + textBoxName.Location = new Point(109, 27); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(315, 27); + textBoxName.TabIndex = 4; + // + // textBoxCost + // + textBoxCost.Location = new Point(109, 67); + textBoxCost.Name = "textBoxCost"; + textBoxCost.Size = new Size(125, 27); + textBoxCost.TabIndex = 5; + // + // FormComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(455, 158); + Controls.Add(textBoxCost); + Controls.Add(textBoxName); + Controls.Add(labelCostComponent); + Controls.Add(labelComponentName); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormComponent"; + Text = "Компонент"; + Load += FormComponent_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonSave; + private Button buttonCancel; + private Label labelComponentName; + private Label labelCostComponent; + private TextBox textBoxName; + private TextBox textBoxCost; + } +} diff --git a/SnackBarView/FormComponent.cs b/SnackBarView/FormComponent.cs new file mode 100644 index 0000000..9864356 --- /dev/null +++ b/SnackBarView/FormComponent.cs @@ -0,0 +1,84 @@ +using SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System.Windows.Forms; + + +namespace SnackBarView +{ + 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 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); + } + } + } + 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 ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + } +} diff --git a/SnackBarView/FormComponent.resx b/SnackBarView/FormComponent.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SnackBarView/FormComponent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/FormComponents.Designer.cs b/SnackBarView/FormComponents.Designer.cs new file mode 100644 index 0000000..fc46b74 --- /dev/null +++ b/SnackBarView/FormComponents.Designer.cs @@ -0,0 +1,118 @@ +namespace SnackBarView +{ + 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() + { + dataGridView = new DataGridView(); + buttonEdit = new Button(); + buttonAdd = new Button(); + buttonDelete = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, -2); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(459, 453); + dataGridView.TabIndex = 0; + // + // buttonEdit + // + buttonEdit.Location = new Point(522, 78); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(119, 36); + buttonEdit.TabIndex = 1; + buttonEdit.Text = "Изменить"; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonRef_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(522, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(119, 35); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(522, 131); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(119, 40); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDel_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(522, 187); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(119, 40); + buttonRefresh.TabIndex = 4; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonUpd_Click; + // + // FormComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(736, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonDelete); + Controls.Add(buttonAdd); + Controls.Add(buttonEdit); + Controls.Add(dataGridView); + Name = "FormComponents"; + Text = "Компоненты"; + Load += FormComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonEdit; + private Button buttonAdd; + private Button buttonDelete; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/SnackBarView/FormComponents.cs b/SnackBarView/FormComponents.cs new file mode 100644 index 0000000..2d86660 --- /dev/null +++ b/SnackBarView/FormComponents.cs @@ -0,0 +1,109 @@ +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 SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + +namespace SnackBarView +{ + public partial class FormComponents : Form + { + 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) + { + } + } + } + } + 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/SnackBarView/FormComponents.resx b/SnackBarView/FormComponents.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SnackBarView/FormComponents.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/FormCreateOrder.Designer.cs b/SnackBarView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..f40d2e5 --- /dev/null +++ b/SnackBarView/FormCreateOrder.Designer.cs @@ -0,0 +1,143 @@ +namespace SnackBarView +{ + 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() + { + labelSnack = new Label(); + labelCount = new Label(); + labelSum = new Label(); + comboBoxSnack = new ComboBox(); + textBoxCount = new TextBox(); + textBoxSum = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelSnack + // + labelSnack.AutoSize = true; + labelSnack.Location = new Point(12, 22); + labelSnack.Name = "labelSnack"; + labelSnack.Size = new Size(64, 20); + labelSnack.TabIndex = 0; + labelSnack.Text = "Закуска:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 65); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 1; + labelCount.Text = "Количество:"; + // + // labelSum + // + labelSum.AutoSize = true; + labelSum.Location = new Point(12, 103); + labelSum.Name = "labelSum"; + labelSum.Size = new Size(58, 20); + labelSum.TabIndex = 2; + labelSum.Text = "Сумма:"; + // + // comboBoxSnack + // + comboBoxSnack.FormattingEnabled = true; + comboBoxSnack.Location = new Point(111, 19); + comboBoxSnack.Name = "comboBoxSnack"; + comboBoxSnack.Size = new Size(238, 28); + comboBoxSnack.TabIndex = 3; + comboBoxSnack.SelectedIndexChanged += ComboBoxSnack_SelectedIndexChanged; + // + // textBoxCount + // + textBoxCount.Location = new Point(111, 58); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(238, 27); + textBoxCount.TabIndex = 4; + textBoxCount.TextChanged += TextBoxCount_TextChanged; + // + // textBoxSum + // + textBoxSum.Location = new Point(111, 100); + textBoxSum.Name = "textBoxSum"; + textBoxSum.Size = new Size(238, 27); + textBoxSum.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(111, 157); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 43); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(234, 157); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(115, 43); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormCreateOrder + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(412, 212); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxSum); + Controls.Add(textBoxCount); + Controls.Add(comboBoxSnack); + Controls.Add(labelSum); + Controls.Add(labelCount); + Controls.Add(labelSnack); + Name = "FormCreateOrder"; + Text = "Заказ"; + Load += FormCreateOrder_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelSnack; + private Label labelCount; + private Label labelSum; + private ComboBox comboBoxSnack; + private TextBox textBoxCount; + private TextBox textBoxSum; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/SnackBarView/FormCreateOrder.cs b/SnackBarView/FormCreateOrder.cs new file mode 100644 index 0000000..c2e2926 --- /dev/null +++ b/SnackBarView/FormCreateOrder.cs @@ -0,0 +1,120 @@ +using SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.SearchModels; +using SnackBarContracts.ViewModels; +using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; +using System.Windows.Forms; + +namespace SnackBarView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + + private readonly ISnackLogic _logicIC; + + private readonly IOrderLogic _logicO; + + public FormCreateOrder(ILogger logger, ISnackLogic logicIC, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicIC = logicIC; + _logicO = logicO; + } + + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Loading snack for order"); + try + { + var iceCreamList = _logicIC.ReadList(null); + if (iceCreamList != null) + { + comboBoxSnack.DisplayMember = "SnackName"; + comboBoxSnack.ValueMember = "Id"; + comboBoxSnack.DataSource = iceCreamList; + comboBoxSnack.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading snack for order"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void CalcSum() + { + if (comboBoxSnack.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxSnack.SelectedValue); + var product = _logicIC.ReadElement(new SnackSearchModel { Id = id }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); + _logger.LogInformation("Calculation of order sum"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Calculation of order sum error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void ComboBoxSnack_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxSnack.SelectedValue == null) + { + MessageBox.Show("Выберите закуску", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Order creation"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + SnackId = Convert.ToInt32(comboBoxSnack.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, "Order creation error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/SnackBarView/FormCreateOrder.resx b/SnackBarView/FormCreateOrder.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SnackBarView/FormCreateOrder.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/FormMain.Designer.cs b/SnackBarView/FormMain.Designer.cs new file mode 100644 index 0000000..600ad08 --- /dev/null +++ b/SnackBarView/FormMain.Designer.cs @@ -0,0 +1,174 @@ +namespace SnackBarView +{ + 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() + { + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + компонентыToolStripMenuItem = new ToolStripMenuItem(); + закускаToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonUpd = new Button(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1146, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, закускаToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // компонентыToolStripMenuItem + // + компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + компонентыToolStripMenuItem.Size = new Size(224, 26); + компонентыToolStripMenuItem.Text = "Компоненты"; + компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; + // + // закускаToolStripMenuItem + // + закускаToolStripMenuItem.Name = "закускаToolStripMenuItem"; + закускаToolStripMenuItem.Size = new Size(224, 26); + закускаToolStripMenuItem.Text = "Закуска"; + закускаToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click; + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 31); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(916, 407); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(934, 58); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(200, 37); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(934, 112); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(200, 37); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(934, 166); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(200, 37); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += ButtonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(934, 222); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(200, 37); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(934, 277); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(200, 37); + buttonUpd.TabIndex = 6; + buttonUpd.Text = "Обновить список"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1146, 450); + Controls.Add(buttonUpd); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Закусочная"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonUpd; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem закускаToolStripMenuItem; + } +} \ No newline at end of file diff --git a/SnackBarView/FormMain.cs b/SnackBarView/FormMain.cs new file mode 100644 index 0000000..2b884f1 --- /dev/null +++ b/SnackBarView/FormMain.cs @@ -0,0 +1,170 @@ +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 SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using SnackBarDataModels.Enums; + +namespace SnackBarView +{ + public partial class FormMain : Form + { + 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() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["SnackId"].Visible = false; + dataGridView.Columns["SnackName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Orders loading"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Orders loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + + private void ЗакускаToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnacks)); + if (service is FormSnacks form) + { + form.ShowDialog(); + } + } + + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + + 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("Order №{id}. Status changes to 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error taking an order to work"); + 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("Order №{id}. Status changes to 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Order readiness marking error"); + 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("Order №{id}. Status changes to 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Order №{id} issued", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Order issue marking error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + LoadData(); + } + private OrderBindingModel CreateBindingModel(int id) + { + return new OrderBindingModel + { + Id = id, + SnackId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SnackId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = (System.DateTime)dataGridView.SelectedRows[0].Cells["DateCreate"].Value, + }; + } + } +} diff --git a/SnackBarView/FormMain.resx b/SnackBarView/FormMain.resx new file mode 100644 index 0000000..6c82d08 --- /dev/null +++ b/SnackBarView/FormMain.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/FormSnack.Designer.cs b/SnackBarView/FormSnack.Designer.cs new file mode 100644 index 0000000..4aa9535 --- /dev/null +++ b/SnackBarView/FormSnack.Designer.cs @@ -0,0 +1,234 @@ +namespace SnackBarView +{ + partial class FormSnack + { + /// + /// 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() + { + labelName = new Label(); + labelPrice = new Label(); + textBoxName = new TextBox(); + textBoxPrice = new TextBox(); + groupBoxComponents = new GroupBox(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonEdit = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + Columnid = new DataGridViewTextBoxColumn(); + ColumnName = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + buttonSave = new Button(); + buttonCancel = new Button(); + groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(80, 20); + labelName.TabIndex = 0; + labelName.Text = "Название:"; + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Location = new Point(12, 56); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(86, 20); + labelPrice.TabIndex = 1; + labelPrice.Text = "Стоимость:"; + // + // textBoxName + // + textBoxName.Location = new Point(98, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(298, 27); + textBoxName.TabIndex = 2; + // + // textBoxPrice + // + textBoxPrice.Location = new Point(98, 53); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(190, 27); + textBoxPrice.TabIndex = 3; + // + // groupBoxComponents + // + groupBoxComponents.Controls.Add(buttonUpd); + groupBoxComponents.Controls.Add(buttonDel); + groupBoxComponents.Controls.Add(buttonEdit); + groupBoxComponents.Controls.Add(buttonAdd); + groupBoxComponents.Controls.Add(dataGridView); + groupBoxComponents.Location = new Point(12, 86); + groupBoxComponents.Name = "groupBoxComponents"; + groupBoxComponents.Size = new Size(776, 351); + groupBoxComponents.TabIndex = 4; + groupBoxComponents.TabStop = false; + groupBoxComponents.Text = "Компоненты"; + // + // buttonUpd + // + buttonUpd.Location = new Point(622, 205); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(118, 36); + buttonUpd.TabIndex = 4; + buttonUpd.Text = "Обновить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.Location = new Point(622, 151); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(118, 36); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonEdit + // + buttonEdit.Location = new Point(622, 98); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(118, 36); + buttonEdit.TabIndex = 2; + buttonEdit.Text = "Изменить"; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonEdit_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(622, 41); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(118, 36); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Columnid, ColumnName, ColumnCount }); + dataGridView.Location = new Point(6, 26); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(568, 319); + dataGridView.TabIndex = 0; + // + // Columnid + // + Columnid.HeaderText = "id"; + Columnid.MinimumWidth = 6; + Columnid.Name = "Columnid"; + Columnid.ReadOnly = true; + Columnid.Width = 125; + // + // ColumnName + // + ColumnName.HeaderText = "Компонент"; + ColumnName.MinimumWidth = 6; + ColumnName.Name = "ColumnName"; + ColumnName.ReadOnly = true; + ColumnName.Width = 280; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + ColumnCount.Width = 125; + // + // buttonSave + // + buttonSave.Location = new Point(546, 443); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(118, 36); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(670, 443); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(118, 36); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormSnack + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 491); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBoxComponents); + Controls.Add(textBoxPrice); + Controls.Add(textBoxName); + Controls.Add(labelPrice); + Controls.Add(labelName); + Name = "FormSnack"; + Text = "FormSnack"; + Load += FormSnack_Load; + groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private TextBox textBoxPrice; + private GroupBox groupBoxComponents; + private Button buttonAdd; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Columnid; + private DataGridViewTextBoxColumn ColumnName; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonUpd; + private Button buttonDel; + private Button buttonEdit; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/SnackBarView/FormSnack.cs b/SnackBarView/FormSnack.cs new file mode 100644 index 0000000..f0d132d --- /dev/null +++ b/SnackBarView/FormSnack.cs @@ -0,0 +1,220 @@ +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 SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.SearchModels; +using SnackBarDataModels.Models; +using Microsoft.Extensions.Logging; +using Microsoft.VisualBasic.Logging; +using NLog.Extensions.Logging; + +namespace SnackBarView +{ + public partial class FormSnack : Form + { + private readonly ILogger _logger; + + private readonly ISnackLogic _logic; + + private int? _id; + + private Dictionary _iceCreamComponents; + + public int Id { set { _id = value; } } + + public FormSnack(ILogger logger, ISnackLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _iceCreamComponents = new Dictionary(); + } + + private void FormSnack_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Snack loading"); + try + { + var view = _logic.ReadElement(new SnackSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.SnackName; + textBoxPrice.Text = view.Price.ToString(); + _iceCreamComponents = view.SnackComponents ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Snack loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Snack components loading"); + try + { + if (_iceCreamComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var iceCreamC in _iceCreamComponents) + { + dataGridView.Rows.Add(new object[] { iceCreamC.Key, iceCreamC.Value.Item1.ComponentName, iceCreamC.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Scank components loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); + if (service is FormSnackComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Adding new component: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); + if (_iceCreamComponents.ContainsKey(form.Id)) + { + _iceCreamComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _iceCreamComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); + } + } + } + + private void ButtonEdit_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); + if (service is FormSnackComponent form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _iceCreamComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Component editing: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); + _iceCreamComponents[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("Deletion of component: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value, + dataGridView.SelectedRows[0].Cells[2].Value); + _iceCreamComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + + private void ButtonUpd_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 (_iceCreamComponents == null || _iceCreamComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Snack saving"); + try + { + var model = new SnackBindingModel + { + Id = _id ?? 0, + SnackName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + SnackComponents = _iceCreamComponents + }; + 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, "Snack saving error"); + 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 _iceCreamComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/SnackBarView/FormSnack.resx b/SnackBarView/FormSnack.resx new file mode 100644 index 0000000..f2ab3bf --- /dev/null +++ b/SnackBarView/FormSnack.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/SnackBarView/FormSnackComponent.Designer.cs b/SnackBarView/FormSnackComponent.Designer.cs new file mode 100644 index 0000000..6789c4c --- /dev/null +++ b/SnackBarView/FormSnackComponent.Designer.cs @@ -0,0 +1,118 @@ +namespace SnackBarView +{ + partial class FormSnackComponent + { + /// + /// 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() + { + labelComponent = new Label(); + labelCount = new Label(); + comboBoxComponent = new ComboBox(); + textBoxCount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelComponent + // + labelComponent.AutoSize = true; + labelComponent.Location = new Point(29, 30); + labelComponent.Name = "labelComponent"; + labelComponent.Size = new Size(91, 20); + labelComponent.TabIndex = 0; + labelComponent.Text = "Компонент:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(29, 91); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 1; + labelCount.Text = "Количество:"; + // + // comboBoxComponent + // + comboBoxComponent.FormattingEnabled = true; + comboBoxComponent.Location = new Point(147, 27); + comboBoxComponent.Name = "comboBoxComponent"; + comboBoxComponent.Size = new Size(218, 28); + comboBoxComponent.TabIndex = 2; + // + // textBoxCount + // + textBoxCount.Location = new Point(147, 88); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(218, 27); + textBoxCount.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(147, 155); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(106, 29); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(259, 155); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(106, 29); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormSnackComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(438, 214); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCount); + Controls.Add(comboBoxComponent); + Controls.Add(labelCount); + Controls.Add(labelComponent); + Name = "FormSnackComponent"; + Text = "Компонент закуски"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelComponent; + private Label labelCount; + private ComboBox comboBoxComponent; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/SnackBarView/FormSnackComponent.cs b/SnackBarView/FormSnackComponent.cs new file mode 100644 index 0000000..a893d5c --- /dev/null +++ b/SnackBarView/FormSnackComponent.cs @@ -0,0 +1,87 @@ +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 SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.ViewModels; +using SnackBarDataModels.Models; + +namespace SnackBarView +{ + public partial class FormSnackComponent : 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 FormSnackComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + 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(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/SnackBarView/FormSnackComponent.resx b/SnackBarView/FormSnackComponent.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SnackBarView/FormSnackComponent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/FormSnacks.Designer.cs b/SnackBarView/FormSnacks.Designer.cs new file mode 100644 index 0000000..36aab48 --- /dev/null +++ b/SnackBarView/FormSnacks.Designer.cs @@ -0,0 +1,115 @@ +namespace SnackBarView +{ + partial class FormSnacks + { + /// + /// 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() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonEdit = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(-1, 1); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(544, 448); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(579, 34); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(155, 55); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonEdit + // + buttonEdit.Location = new Point(579, 114); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(155, 55); + buttonEdit.TabIndex = 2; + buttonEdit.Text = "Изменить"; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonEdit_Click; + // + // buttonDel + // + buttonDel.Location = new Point(579, 196); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(155, 55); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(579, 279); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(155, 55); + buttonUpd.TabIndex = 4; + buttonUpd.Text = "Обновить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // FormSnacks + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(771, 450); + Controls.Add(buttonUpd); + Controls.Add(buttonDel); + Controls.Add(buttonEdit); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormSnacks"; + Text = "Закуски"; + Load += FormSnacks_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonEdit; + private Button buttonDel; + private Button buttonUpd; + } +} \ No newline at end of file diff --git a/SnackBarView/FormSnacks.cs b/SnackBarView/FormSnacks.cs new file mode 100644 index 0000000..223fbd5 --- /dev/null +++ b/SnackBarView/FormSnacks.cs @@ -0,0 +1,113 @@ +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 SnackBarContracts.BindingModels; +using SnackBarContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace SnackBarView +{ + public partial class FormSnacks : Form + { + private readonly ILogger _logger; + + private readonly ISnackLogic _logic; + + public FormSnacks(ILogger logger, ISnackLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormSnacks_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["SnackName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SnackComponents"].Visible = false; + } + _logger.LogInformation("Ice creams loading"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ice creams loading error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); + if (service is FormSnack form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonEdit_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); + if (service is FormSnack 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("Deletion of ice cream"); + try + { + if (!_logic.Delete(new SnackBindingModel { Id = id })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ice cream deletion error"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/SnackBarView/FormSnacks.resx b/SnackBarView/FormSnacks.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SnackBarView/FormSnacks.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/SnackBarView/Program.cs b/SnackBarView/Program.cs index d145eb5..dcf07d6 100644 --- a/SnackBarView/Program.cs +++ b/SnackBarView/Program.cs @@ -1,7 +1,17 @@ +using SnackBarBusinessLogic.BusinessLogics; +using SnackBarContracts.BusinessLogicsContracts; +using SnackBarContracts.StoragesContracts; +using SnackBarListImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + namespace SnackBarView { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +21,33 @@ namespace SnackBarView // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + 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/SnackBarView/Properties/Resources.Designer.cs b/SnackBarView/Properties/Resources.Designer.cs new file mode 100644 index 0000000..51ee88a --- /dev/null +++ b/SnackBarView/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace SnackBarView.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SnackBarView.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/SnackBarView/Form1.resx b/SnackBarView/Properties/Resources.resx similarity index 100% rename from SnackBarView/Form1.resx rename to SnackBarView/Properties/Resources.resx diff --git a/SnackBarView/SnackBarView.csproj b/SnackBarView/SnackBarView.csproj index b57c89e..074d265 100644 --- a/SnackBarView/SnackBarView.csproj +++ b/SnackBarView/SnackBarView.csproj @@ -8,4 +8,18 @@ enable + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SnackBarView/SnackBarView.sln b/SnackBarView/SnackBarView.sln index 76aaa65..4bf7f75 100644 --- a/SnackBarView/SnackBarView.sln +++ b/SnackBarView/SnackBarView.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34525.116 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarView", "SnackBarView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SnackBarView", "SnackBarView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarListImplement", "..\SnackBarListImplement\SnackBarListImplement.csproj", "{9D223B95-71A3-4914-9532-A4D8B31288FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarDataModels", "..\SnackBarDataModels\SnackBarDataModels.csproj", "{11F46ADA-6833-42AD-BF19-78A7826BC741}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarContracts", "..\SnackBarContracts\SnackBarContracts.csproj", "{E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarBusinessLogic", "..\SnackBarBusinessLogic\SnackBarBusinessLogic.csproj", "{1057A33D-538D-4E7F-862B-1FF8E9E021A0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +23,22 @@ Global {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.ActiveCfg = Release|Any CPU {F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}.Release|Any CPU.Build.0 = Release|Any CPU + {9D223B95-71A3-4914-9532-A4D8B31288FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D223B95-71A3-4914-9532-A4D8B31288FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D223B95-71A3-4914-9532-A4D8B31288FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D223B95-71A3-4914-9532-A4D8B31288FD}.Release|Any CPU.Build.0 = Release|Any CPU + {11F46ADA-6833-42AD-BF19-78A7826BC741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11F46ADA-6833-42AD-BF19-78A7826BC741}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11F46ADA-6833-42AD-BF19-78A7826BC741}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11F46ADA-6833-42AD-BF19-78A7826BC741}.Release|Any CPU.Build.0 = Release|Any CPU + {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}.Release|Any CPU.Build.0 = Release|Any CPU + {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1057A33D-538D-4E7F-862B-1FF8E9E021A0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SnackBarView/nlog.config b/SnackBarView/nlog.config new file mode 100644 index 0000000..85797a7 --- /dev/null +++ b/SnackBarView/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file