diff --git a/Confectionery/Confectionery.sln b/Confectionery/Confectionery.sln index 5fa8fc7..52d0699 100644 --- a/Confectionery/Confectionery.sln +++ b/Confectionery/Confectionery.sln @@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.32112.339 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryDataModels", "ConfectioneryDataModels\ConfectioneryDataModels.csproj", "{D7A8174D-1B45-4463-A4D7-C82CA529EE4D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryDataModels", "ConfectioneryDataModels\ConfectioneryDataModels.csproj", "{D7A8174D-1B45-4463-A4D7-C82CA529EE4D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryContracts", "ConfectioneryContracts\ConfectioneryContracts.csproj", "{C151D91F-BDB0-46AD-8573-3F6174E9E76A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryContracts", "ConfectioneryContracts\ConfectioneryContracts.csproj", "{C151D91F-BDB0-46AD-8573-3F6174E9E76A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryView", "ConfectioneryView\ConfectioneryView.csproj", "{B222E04E-D0E7-49F4-8747-426125645B93}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryView", "ConfectioneryView\ConfectioneryView.csproj", "{B222E04E-D0E7-49F4-8747-426125645B93}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryBusinessLogic", "ConfectioneryBusinessLogic\ConfectioneryBusinessLogic.csproj", "{40859695-0BD6-49A8-8997-AD76F6984144}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryListImplement", "ConfectioneryListImplement\ConfectioneryListImplement.csproj", "{8B6BFE3A-CA63-4FCB-B7AC-DB3F28E0F7A7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +31,14 @@ Global {B222E04E-D0E7-49F4-8747-426125645B93}.Debug|Any CPU.Build.0 = Debug|Any CPU {B222E04E-D0E7-49F4-8747-426125645B93}.Release|Any CPU.ActiveCfg = Release|Any CPU {B222E04E-D0E7-49F4-8747-426125645B93}.Release|Any CPU.Build.0 = Release|Any CPU + {40859695-0BD6-49A8-8997-AD76F6984144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40859695-0BD6-49A8-8997-AD76F6984144}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40859695-0BD6-49A8-8997-AD76F6984144}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40859695-0BD6-49A8-8997-AD76F6984144}.Release|Any CPU.Build.0 = Release|Any CPU + {8B6BFE3A-CA63-4FCB-B7AC-DB3F28E0F7A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B6BFE3A-CA63-4FCB-B7AC-DB3F28E0F7A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B6BFE3A-CA63-4FCB-B7AC-DB3F28E0F7A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B6BFE3A-CA63-4FCB-B7AC-DB3F28E0F7A7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ComponentLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ComponentLogic.cs new file mode 100644 index 0000000..0131360 --- /dev/null +++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -0,0 +1,127 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.StoragesContracts; +using ConfectioneryContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.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/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/OrderLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..2b3ecca --- /dev/null +++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,132 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.StoragesContracts; +using ConfectioneryContracts.ViewModels; +using ConfectioneryDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.BusinessLogics +{ + internal class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + { + _logger.LogWarning("Insert operation failed. Order status incorrect."); + return false; + } + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + model.Status = OrderStatus.Неизвестен; + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) + { + var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (viewModel == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (viewModel.Status + 1 != newStatus) + { + _logger.LogWarning("Update operation failed. Order status incorrect."); + return false; + } + model.Status = newStatus; + if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now; + else + { + model.DateImplement = viewModel.DateImplement; + } + CheckModel(model); + if (_orderStorage.Update(model) == null) + { + model.Status--; + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выдан); + } + + public bool FinishOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Готов); + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выполняется); + } + + 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; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if(model.PastryId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор документа", + nameof(model.PastryId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество кондитерских изделий в заказе должно быть больше 0", + nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", + nameof(model.Sum)); + } + _logger.LogInformation("Pastry. OrderId:{Id}. Sum:{Sum}. PastryId:{PastryId}.", + model.Id, model.Sum, model.PastryId); + } + } +} diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/PastryLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/PastryLogic.cs new file mode 100644 index 0000000..416ec00 --- /dev/null +++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/PastryLogic.cs @@ -0,0 +1,121 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.StoragesContracts; +using ConfectioneryContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.BusinessLogics +{ + public class PastryLogic : IPastryLogic + { + private readonly ILogger _logger; + + private readonly IPastryStorage _pastryStorage; + + public PastryLogic(ILogger logger, IPastryStorage pastryStorage) + { + _logger = logger; + _pastryStorage = pastryStorage; + } + + public List? ReadList(PastrySearchModel? model) + { + _logger.LogInformation("ReadList. PastryName:{PastryName}. Id:{Id}", model?.PastryName, model?.Id); + var list = model == null ? _pastryStorage.GetFullList() : _pastryStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public PastryViewModel? ReadElement(PastrySearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. PastryName:{PastryName}. Id:{Id}", model.PastryName, model.Id); + var element = _pastryStorage.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(PastryBindingModel model) + { + CheckModel(model); + if (_pastryStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(PastryBindingModel model) + { + CheckModel(model); + if (_pastryStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(PastryBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_pastryStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(PastryBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.PastryName)) + { + throw new ArgumentNullException("Нет названия кондитерского изделия", nameof(model.PastryName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена кондитерского изделия должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Pastry. PastryName:{PastryName}. Cost:{Cost}. Id:{Id}", + model.PastryName, model.Price, model.Id); + var element = _pastryStorage.GetElement(new PastrySearchModel + { + PastryName = model.PastryName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Кондитерское изделие с таким названием уже есть"); + } + } + } +} diff --git a/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj b/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj new file mode 100644 index 0000000..4590d1c --- /dev/null +++ b/Confectionery/ConfectioneryBusinessLogic/ConfectioneryBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs index c367c94..7859c0f 100644 --- a/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs +++ b/Confectionery/ConfectioneryContracts/BindingModels/OrderBindingModel.cs @@ -12,7 +12,7 @@ namespace ConfectioneryContracts.BindingModels { public int Id { get; set; } - public int ProductId { get; set; } + public int PastryId { get; set; } public int Count { get; set; } diff --git a/Confectionery/ConfectioneryContracts/BindingModels/ProductBindingModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/PastryBindingModel.cs similarity index 59% rename from Confectionery/ConfectioneryContracts/BindingModels/ProductBindingModel.cs rename to Confectionery/ConfectioneryContracts/BindingModels/PastryBindingModel.cs index ab4bf89..9649fb5 100644 --- a/Confectionery/ConfectioneryContracts/BindingModels/ProductBindingModel.cs +++ b/Confectionery/ConfectioneryContracts/BindingModels/PastryBindingModel.cs @@ -7,14 +7,14 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.BindingModels { - public class ProductBindingModel : IProductModel + public class PastryBindingModel : IPastryModel { public int Id { get; set; } - public string ProductName { get; set; } = string.Empty; + public string PastryName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary ProductComponents { get; set; } = new(); + public Dictionary PastryComponents { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..d832f16 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,24 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.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/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..96501ad --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,24 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.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/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs new file mode 100644 index 0000000..106936e --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs @@ -0,0 +1,24 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.BusinessLogicsContracts +{ + public interface IPastryLogic + { + List? ReadList(PastrySearchModel? model); + + PastryViewModel? ReadElement(PastrySearchModel model); + + bool Create(PastryBindingModel model); + + bool Update(PastryBindingModel model); + + bool Delete(PastryBindingModel model); + } +} diff --git a/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj b/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj index 1bf7525..b0b970c 100644 --- a/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj +++ b/Confectionery/ConfectioneryContracts/ConfectioneryContracts.csproj @@ -10,9 +10,4 @@ - - - - - diff --git a/Confectionery/ConfectioneryContracts/SearchModels/ProductSearchModel.cs b/Confectionery/ConfectioneryContracts/SearchModels/PastrySearchModel.cs similarity index 72% rename from Confectionery/ConfectioneryContracts/SearchModels/ProductSearchModel.cs rename to Confectionery/ConfectioneryContracts/SearchModels/PastrySearchModel.cs index 56afdb9..5e0280b 100644 --- a/Confectionery/ConfectioneryContracts/SearchModels/ProductSearchModel.cs +++ b/Confectionery/ConfectioneryContracts/SearchModels/PastrySearchModel.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.SearchModels { - public class ProductSearchModel + public class PastrySearchModel { public int? Id { get; set; } - public string? ProductName { get; set; } + public string? PastryName { get; set; } } } diff --git a/Confectionery/ConfectioneryContracts/StoragesContracts/IComponentStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..6205d5a --- /dev/null +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,26 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.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/Confectionery/ConfectioneryContracts/StoragesContracts/IOrderStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..ae004e6 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,26 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.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/Confectionery/ConfectioneryContracts/StoragesContracts/IPastryStorage.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IPastryStorage.cs new file mode 100644 index 0000000..7fce161 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IPastryStorage.cs @@ -0,0 +1,26 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.SearchModels; +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.StoragesContracts +{ + public interface IPastryStorage + { + List GetFullList(); + + List GetFilteredList(PastrySearchModel model); + + PastryViewModel? GetElement(PastrySearchModel model); + + PastryViewModel? Insert(PastryBindingModel model); + + PastryViewModel? Update(PastryBindingModel model); + + PastryViewModel? Delete(PastryBindingModel model); + } +} diff --git a/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs index 4c3711d..bb20d71 100644 --- a/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs +++ b/Confectionery/ConfectioneryContracts/ViewModels/OrderViewModel.cs @@ -14,10 +14,10 @@ namespace ConfectioneryContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } - public int ProductId { get; set; } + public int PastryId { get; set; } [DisplayName("Изделие")] - public string ProductName { get; set; } = string.Empty; + public string PastryName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } diff --git a/Confectionery/ConfectioneryContracts/ViewModels/ProductViewModel.cs b/Confectionery/ConfectioneryContracts/ViewModels/PastryViewModel.cs similarity index 66% rename from Confectionery/ConfectioneryContracts/ViewModels/ProductViewModel.cs rename to Confectionery/ConfectioneryContracts/ViewModels/PastryViewModel.cs index 961999e..5d1919f 100644 --- a/Confectionery/ConfectioneryContracts/ViewModels/ProductViewModel.cs +++ b/Confectionery/ConfectioneryContracts/ViewModels/PastryViewModel.cs @@ -8,16 +8,16 @@ using System.Threading.Tasks; namespace ConfectioneryContracts.ViewModels { - public class ProductViewModel : IProductModel + public class PastryViewModel : IPastryModel { public int Id { get; set; } [DisplayName("Название изделия")] - public string ProductName { get; set; } = string.Empty; + public string PastryName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary ProductComponents { get; set; } = new(); + public Dictionary PastryComponents { get; set; } = new(); } } diff --git a/Confectionery/ConfectioneryDataModels/Models/IOrderModel.cs b/Confectionery/ConfectioneryDataModels/Models/IOrderModel.cs index 39fb31e..8f73357 100644 --- a/Confectionery/ConfectioneryDataModels/Models/IOrderModel.cs +++ b/Confectionery/ConfectioneryDataModels/Models/IOrderModel.cs @@ -9,7 +9,7 @@ namespace ConfectioneryDataModels.Models { public interface IOrderModel : IId { - int ProductId { get; } + int PastryId { get; } int Count { get; } diff --git a/Confectionery/ConfectioneryDataModels/Models/IProductModel.cs b/Confectionery/ConfectioneryDataModels/Models/IPastryModel.cs similarity index 57% rename from Confectionery/ConfectioneryDataModels/Models/IProductModel.cs rename to Confectionery/ConfectioneryDataModels/Models/IPastryModel.cs index 1831847..0d2b1c4 100644 --- a/Confectionery/ConfectioneryDataModels/Models/IProductModel.cs +++ b/Confectionery/ConfectioneryDataModels/Models/IPastryModel.cs @@ -6,12 +6,12 @@ using System.Threading.Tasks; namespace ConfectioneryDataModels.Models { - public interface IProductModel : IId + public interface IPastryModel : IId { - string ProductName { get; } + string PastryName { get; } double Price { get; } - Dictionary ProductComponents { get; } + Dictionary PastryComponents { get; } } } diff --git a/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj b/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj new file mode 100644 index 0000000..41b6c3e --- /dev/null +++ b/Confectionery/ConfectioneryListImplement/ConfectioneryListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + +