diff --git a/Pizzeria/Pizzeria.sln b/Pizzeria/Pizzeria.sln index 0e88e84..a3d502f 100644 --- a/Pizzeria/Pizzeria.sln +++ b/Pizzeria/Pizzeria.sln @@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pizzeria", "Pizzeria\Pizzeria.csproj", "{F0E7F0CB-FCF9-4BBA-9A84-0F5B3318699E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pizzeria", "Pizzeria\Pizzeria.csproj", "{F0E7F0CB-FCF9-4BBA-9A84-0F5B3318699E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaDataModels", "PizzeriaDataModels\PizzeriaDataModels.csproj", "{3EA8DCDC-7829-4CF4-956E-C611BBC4AD53}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaContracts", "PizzeriaContracts\PizzeriaContracts.csproj", "{E247AAD5-A284-4A21-8CFA-99732E7C2DC8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaBusinessLogic", "PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj", "{D8EAAB67-47C6-443D-83FC-E1337F105F67}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +21,18 @@ Global {F0E7F0CB-FCF9-4BBA-9A84-0F5B3318699E}.Debug|Any CPU.Build.0 = Debug|Any CPU {F0E7F0CB-FCF9-4BBA-9A84-0F5B3318699E}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0E7F0CB-FCF9-4BBA-9A84-0F5B3318699E}.Release|Any CPU.Build.0 = Release|Any CPU + {3EA8DCDC-7829-4CF4-956E-C611BBC4AD53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EA8DCDC-7829-4CF4-956E-C611BBC4AD53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EA8DCDC-7829-4CF4-956E-C611BBC4AD53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EA8DCDC-7829-4CF4-956E-C611BBC4AD53}.Release|Any CPU.Build.0 = Release|Any CPU + {E247AAD5-A284-4A21-8CFA-99732E7C2DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E247AAD5-A284-4A21-8CFA-99732E7C2DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E247AAD5-A284-4A21-8CFA-99732E7C2DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E247AAD5-A284-4A21-8CFA-99732E7C2DC8}.Release|Any CPU.Build.0 = Release|Any CPU + {D8EAAB67-47C6-443D-83FC-E1337F105F67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8EAAB67-47C6-443D-83FC-E1337F105F67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8EAAB67-47C6-443D-83FC-E1337F105F67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8EAAB67-47C6-443D-83FC-E1337F105F67}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Pizzeria/PizzeriaBusinessLogic/ComponentLogic.cs b/Pizzeria/PizzeriaBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..17a3961 --- /dev/null +++ b/Pizzeria/PizzeriaBusinessLogic/ComponentLogic.cs @@ -0,0 +1,114 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StorageContracts; +using PizzeriaContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaBusinessLogic +{ + 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/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..8002bf0 --- /dev/null +++ b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs @@ -0,0 +1,120 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StorageContracts; +using PizzeriaContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PizzeriaDataModels; + +namespace PizzeriaBusinessLogic +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Count <= 0) + { + throw new ArgumentException("Количество изделий в заказе не может быть меньше 1", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum)); + } + if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) + { + throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); + } + _logger.LogInformation("Reinforced. ReinforcedId:{ReinforcedId}.Count:{Count}.Sum:{Sum}Id:{Id}", + model.ProductId, model.Count, model.Sum, model.Id); + } + private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel() + { + Id = model.Id + }); + if (element == null) + { + throw new ArgumentNullException(nameof(element)); + } + model.DateCreate = element.DateCreate; + model.ProductId = element.ProductId; + model.DateImplement = element.DateImplement; + model.Status = element.Status; + model.Count = element.Count; + model.Sum = element.Sum; + if (requiredStatus - model.Status == 1) + { + model.Status = requiredStatus; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); + } + } +} diff --git a/Pizzeria/PizzeriaBusinessLogic/PizzaLogic.cs b/Pizzeria/PizzeriaBusinessLogic/PizzaLogic.cs new file mode 100644 index 0000000..8c9a0fb --- /dev/null +++ b/Pizzeria/PizzeriaBusinessLogic/PizzaLogic.cs @@ -0,0 +1,116 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StorageContracts; +using PizzeriaContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaBusinessLogic +{ + public class PizzaLogic : IPizzaLogic + { + private readonly ILogger _logger; + private readonly IPizzaStorage _pizzaStorage; + public PizzaLogic(ILogger logger, IPizzaStorage pizzaStorage) + { + _logger = logger; + _pizzaStorage = pizzaStorage; + } + public List? ReadList(PizzaSearchModel? model) + { + _logger.LogInformation("ReadList. PizzaName:{PizzaName}.Id:{ Id}", model?.ProductName, model?.Id); + var list = model == null ? _pizzaStorage.GetFullList() : _pizzaStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public PizzaViewModel? ReadElement(PizzaSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. PizzaName:{PizzaName}.Id:{ Id}", model.ProductName, model.Id); + var element = _pizzaStorage.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(PizzaBindingModel model) + { + CheckModel(model); + if (_pizzaStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(PizzaBindingModel model) + { + CheckModel(model); + if (_pizzaStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(PizzaBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_pizzaStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(PizzaBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ProductName)) + { + throw new ArgumentNullException("Нет названия изделия", nameof(model.ProductName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); + } + if (model.ProductComponents == null || model.ProductComponents.Count == 0) + { + throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.ProductComponents)); + } + _logger.LogInformation("Pizza. PizzaName:{PizzaName}.Price:{Price}.Id: { Id}", model.ProductName, model.Price, model.Id); + var element = _pizzaStorage.GetElement(new PizzaSearchModel + { + ProductName = model.ProductName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Изделие с таким названием уже есть"); + } + } + } +} diff --git a/Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj b/Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj new file mode 100644 index 0000000..7c031e8 --- /dev/null +++ b/Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..11fb5cb --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,17 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..42eef98 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,20 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int ProductId { 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/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs new file mode 100644 index 0000000..9cc1ce1 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs @@ -0,0 +1,21 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.BindingModels +{ + public class PizzaBindingModel : IPrizzaModel + { + public int Id { get; set; } + public string ProductName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary ProductComponents + { + get; + set; + } = new(); + } +} diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..3c12d63 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,21 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..f95ecfa --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,21 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs new file mode 100644 index 0000000..c1653f0 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs @@ -0,0 +1,21 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.BusinessLogicsContracts +{ + public interface IPizzaLogic + { + List? ReadList(PizzaSearchModel? model); + PizzaViewModel? ReadElement(PizzaSearchModel model); + bool Create(PizzaBindingModel model); + bool Update(PizzaBindingModel model); + bool Delete(PizzaBindingModel model); + } + +} diff --git a/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj new file mode 100644 index 0000000..f8743a9 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..79ddaad --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..3695879 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs new file mode 100644 index 0000000..5561e40 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class PizzaSearchModel + { + public int? Id { get; set; } + public string? ProductName { get; set; } + } + +} diff --git a/Pizzeria/PizzeriaContracts/StorageContracts/IComponentStorage.cs b/Pizzeria/PizzeriaContracts/StorageContracts/IComponentStorage.cs new file mode 100644 index 0000000..3d9dd83 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StorageContracts/IComponentStorage.cs @@ -0,0 +1,22 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.StorageContracts +{ + 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/Pizzeria/PizzeriaContracts/StorageContracts/IOrderStorage.cs b/Pizzeria/PizzeriaContracts/StorageContracts/IOrderStorage.cs new file mode 100644 index 0000000..ec75bc0 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StorageContracts/IOrderStorage.cs @@ -0,0 +1,22 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.StorageContracts +{ + 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/Pizzeria/PizzeriaContracts/StorageContracts/IPizzaStorage.cs b/Pizzeria/PizzeriaContracts/StorageContracts/IPizzaStorage.cs new file mode 100644 index 0000000..a20a690 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StorageContracts/IPizzaStorage.cs @@ -0,0 +1,22 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.StorageContracts +{ + public interface IPizzaStorage + { + List GetFullList(); + List GetFilteredList(PizzaSearchModel model); + PizzaViewModel? GetElement(PizzaSearchModel model); + PizzaViewModel? Insert(PizzaBindingModel model); + PizzaViewModel? Update(PizzaBindingModel model); + PizzaViewModel? Delete(PizzaBindingModel model); + } + +} diff --git a/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..7a74786 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,20 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..8ddf93e --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,30 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int ProductId { get; set; } + [DisplayName("Изделие")] + public string ProductName { 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/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs new file mode 100644 index 0000000..9964076 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs @@ -0,0 +1,25 @@ +using PizzeriaDataModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.ViewModels +{ + public class PizzaViewModel : IPrizzaModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string ProductName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary ProductComponents + { + get; + set; + } = new(); + } + +} diff --git a/Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs b/Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..50358b8 --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } + +} diff --git a/Pizzeria/PizzeriaDataModels/IId.cs b/Pizzeria/PizzeriaDataModels/IId.cs new file mode 100644 index 0000000..f7e3b49 --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs b/Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..f228150 --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs b/Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..189bedb --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels +{ + public interface IOrderModel : IId + { + int ProductId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } + +} diff --git a/Pizzeria/PizzeriaDataModels/Models/IPrizzaModel.cs b/Pizzeria/PizzeriaDataModels/Models/IPrizzaModel.cs new file mode 100644 index 0000000..3ea36e2 --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/Models/IPrizzaModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels +{ + public interface IPrizzaModel : IId + { + string ProductName { get; } + double Price { get; } + Dictionary ProductComponents { get; } + } +} diff --git a/Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj b/Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + +