diff --git a/Restaurant/Restaurant.sln b/Restaurant/Restaurant.sln new file mode 100644 index 0000000..e4e41a9 --- /dev/null +++ b/Restaurant/Restaurant.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32819.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestaurantView", "RestaurantView\RestaurantView.csproj", "{6784A2BC-8BA1-48A3-992B-DC0EA755469B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestaurantDataModels", "RestaurantDataModels\RestaurantDataModels.csproj", "{A7888AAA-C1CD-4580-A204-E6720AF49931}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestaurantContracts", "RestaurantContracts\RestaurantContracts.csproj", "{288FB1A3-E6D0-42B2-BA20-463E03F922B4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestaurantBusinessLogic", "RestaurantBusinessLogic\RestaurantBusinessLogic.csproj", "{F3A63C5F-2BAE-4E69-895C-62FC1A7C556D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6784A2BC-8BA1-48A3-992B-DC0EA755469B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6784A2BC-8BA1-48A3-992B-DC0EA755469B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6784A2BC-8BA1-48A3-992B-DC0EA755469B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6784A2BC-8BA1-48A3-992B-DC0EA755469B}.Release|Any CPU.Build.0 = Release|Any CPU + {A7888AAA-C1CD-4580-A204-E6720AF49931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7888AAA-C1CD-4580-A204-E6720AF49931}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7888AAA-C1CD-4580-A204-E6720AF49931}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7888AAA-C1CD-4580-A204-E6720AF49931}.Release|Any CPU.Build.0 = Release|Any CPU + {288FB1A3-E6D0-42B2-BA20-463E03F922B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {288FB1A3-E6D0-42B2-BA20-463E03F922B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {288FB1A3-E6D0-42B2-BA20-463E03F922B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {288FB1A3-E6D0-42B2-BA20-463E03F922B4}.Release|Any CPU.Build.0 = Release|Any CPU + {F3A63C5F-2BAE-4E69-895C-62FC1A7C556D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3A63C5F-2BAE-4E69-895C-62FC1A7C556D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3A63C5F-2BAE-4E69-895C-62FC1A7C556D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3A63C5F-2BAE-4E69-895C-62FC1A7C556D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {32B2C3CA-1147-4363-B638-B2719076B7E2} + EndGlobalSection +EndGlobal diff --git a/Restaurant/RestaurantBusinessLogic/BusinessLogics/ComponentLogic.cs b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ComponentLogic.cs new file mode 100644 index 0000000..604c5ce --- /dev/null +++ b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -0,0 +1,110 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.BusinessLogicsContracts; +using RestaurantContracts.SearchModels; +using RestaurantContracts.StoragesContracts; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly IComponentStorage _componentStorage; + + public ComponentLogic(IComponentStorage componentStorage) + { + _componentStorage = componentStorage; + } + + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + if (_componentStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + var element = _componentStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(ComponentSearchModel? model) + { + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Delete(model) == null) + { + 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.Name)) + { + throw new ArgumentNullException("Нет названия компонента", nameof(model.Name)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Нет цены у компонента", nameof(model.Price)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Нет количества у компонента", nameof(model.Count)); + } + var element = _componentStorage.GetElement(new ComponentSearchModel + { + Name = model.Name, + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким логином уже есть"); + } + } + } +} diff --git a/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs b/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..15a0292 --- /dev/null +++ b/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,105 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.BusinessLogicsContracts; +using RestaurantContracts.SearchModels; +using RestaurantContracts.StoragesContracts; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly IOrderStorage _orderStorage; + + public OrderLogic(IOrderStorage orderStorage) + { + _orderStorage = orderStorage; + } + + public bool Create(OrderBindingModel model) + { + CheckModel(model); + if (_orderStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(OrderBindingModel model) + { + CheckModel(model, false); + if (_orderStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + var element = _orderStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(OrderSearchModel? model) + { + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Update(OrderBindingModel model) + { + CheckModel(model); + if (_orderStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Нет цены у заказа", nameof(model.Price)); + } + if (model.Date != null) + { + throw new ArgumentNullException("Нет даты у заказа", nameof(model.Date)); + } + var element = _orderStorage.GetElement(new OrderSearchModel + { + Date = model.Date, + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Заказ с таким номером уже есть"); + } + } + } +} diff --git a/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProductLogic.cs b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProductLogic.cs new file mode 100644 index 0000000..8831ea2 --- /dev/null +++ b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProductLogic.cs @@ -0,0 +1,110 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.BusinessLogicsContracts; +using RestaurantContracts.SearchModels; +using RestaurantContracts.StoragesContracts; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantBusinessLogic.BusinessLogics +{ + public class ProductLogic : IProductLogic + { + private readonly IProductStorage _productStorage; + + public ProductLogic(IProductStorage productStorage) + { + _productStorage = productStorage; + } + + public bool Create(ProductBindingModel model) + { + CheckModel(model); + if (_productStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(ProductBindingModel model) + { + CheckModel(model, false); + if (_productStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public ProductViewModel? ReadElement(ProductSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + var element = _productStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(ProductSearchModel? model) + { + var list = model == null ? _productStorage.GetFullList() : _productStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Update(ProductBindingModel model) + { + CheckModel(model); + if (_productStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(ProductBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Type)) + { + throw new ArgumentNullException("Нет вида продукта", nameof(model.Type)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Нет цены у продукта", nameof(model.Price)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Нет количества у продукта", nameof(model.Count)); + } + var element = _productStorage.GetElement(new ProductSearchModel + { + Type = model.Type, + + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким логином уже есть"); + } + } + } +} diff --git a/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProviderLogic.cs b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProviderLogic.cs new file mode 100644 index 0000000..95ca862 --- /dev/null +++ b/Restaurant/RestaurantBusinessLogic/BusinessLogics/ProviderLogic.cs @@ -0,0 +1,105 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.BusinessLogicsContracts; +using RestaurantContracts.SearchModels; +using RestaurantContracts.StoragesContracts; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantBusinessLogic.BusinessLogics +{ + public class ProviderLogic : IProviderLogic + { + private readonly IProviderStorage _providerStorage; + + public ProviderLogic(IProviderStorage providerStorage) + { + _providerStorage = providerStorage; + } + + public bool Delete(ProviderBindingModel model) + { + CheckModel(model, false); + if (_providerStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Create(ProviderBindingModel model) + { + CheckModel(model); + if (_providerStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Update(ProviderBindingModel model) + { + CheckModel(model); + if (_providerStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(ProviderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Name)) + { + throw new ArgumentNullException("Нет названия поставщика", nameof(model.Name)); + } + if (string.IsNullOrEmpty(model.Address)) + { + throw new ArgumentNullException("Нет адресса", nameof(model.Address)); + } + var element = _providerStorage.GetElement(new ProviderSearchModel + { + Name = model.Name, + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Поставщик с таким названием уже есть"); + } + } + + public List? ReadList(ProviderSearchModel? model) + { + var list = (model == null) ? _providerStorage.GetFullList() : _providerStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public ProviderViewModel? ReadElement(ProviderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + var element = _providerStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + } +} diff --git a/Restaurant/RestaurantBusinessLogic/RestaurantBusinessLogic.csproj b/Restaurant/RestaurantBusinessLogic/RestaurantBusinessLogic.csproj new file mode 100644 index 0000000..2e73ee3 --- /dev/null +++ b/Restaurant/RestaurantBusinessLogic/RestaurantBusinessLogic.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Restaurant/RestaurantContracts/BindingModels/ClientBindingModel.cs b/Restaurant/RestaurantContracts/BindingModels/ClientBindingModel.cs new file mode 100644 index 0000000..15c673c --- /dev/null +++ b/Restaurant/RestaurantContracts/BindingModels/ClientBindingModel.cs @@ -0,0 +1,20 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BindingModels +{ + public class ClientBindingModel : IClientModel + { + public string FirstName { get; set; } = string.Empty; + + public string LastName { get; set; } = string.Empty; + + public string Number { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/BindingModels/ComponentBindingModel.cs b/Restaurant/RestaurantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..5972da5 --- /dev/null +++ b/Restaurant/RestaurantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,22 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public string Name { get; set; } = string.Empty; + + public int Price { get; set; } + + public int Count { get; set; } + + public Dictionary ComponentProviders { get; set; } = new(); + + public int Id { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/BindingModels/OrderBindingModel.cs b/Restaurant/RestaurantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..23f5e8b --- /dev/null +++ b/Restaurant/RestaurantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,22 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int ClientId { get; set; } = new(); + + public int Price { get; set; } + + public DateTime Date { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + + public Dictionary OrderProducts { get; set; } = new(); + + public int Id { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/BindingModels/ProductBindingModel.cs b/Restaurant/RestaurantContracts/BindingModels/ProductBindingModel.cs new file mode 100644 index 0000000..1f32c8f --- /dev/null +++ b/Restaurant/RestaurantContracts/BindingModels/ProductBindingModel.cs @@ -0,0 +1,22 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BindingModels +{ + public class ProductBindingModel : IProductModel + { + public string Type { get; set; } = string.Empty; + + public int Price { get; set; } + + public int Count { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + + public int Id { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/BindingModels/ProviderBindingModel.cs b/Restaurant/RestaurantContracts/BindingModels/ProviderBindingModel.cs new file mode 100644 index 0000000..c5cf9dc --- /dev/null +++ b/Restaurant/RestaurantContracts/BindingModels/ProviderBindingModel.cs @@ -0,0 +1,18 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BindingModels +{ + public class ProviderBindingModel : IProviderModel + { + public string Name { get; set; } = string.Empty; + + public string Address { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IClientLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IClientLogic.cs new file mode 100644 index 0000000..05c955e --- /dev/null +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IClientLogic.cs @@ -0,0 +1,20 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BusinessLogicsContracts +{ + public interface IClientLogic + { + List? ReadList(ClientSearchModel? model); + ClientViewModel? ReadElement(ClientSearchModel model); + bool Create(ClientBindingModel model); + bool Update(ClientBindingModel model); + bool Delete(ClientBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IComponentLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..247b64c --- /dev/null +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,24 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.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/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..666a59c --- /dev/null +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,24 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + + OrderViewModel? ReadElement(OrderSearchModel model); + + bool Create(OrderBindingModel model); + + bool Update(OrderBindingModel model); + + bool Delete(OrderBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProductLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProductLogic.cs new file mode 100644 index 0000000..9bb196d --- /dev/null +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProductLogic.cs @@ -0,0 +1,24 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BusinessLogicsContracts +{ + public interface IProductLogic + { + List? ReadList(ProductSearchModel? model); + + ProductViewModel? ReadElement(ProductSearchModel model); + + bool Create(ProductBindingModel model); + + bool Update(ProductBindingModel model); + + bool Delete(ProductBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProviderLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProviderLogic.cs new file mode 100644 index 0000000..961f2ae --- /dev/null +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IProviderLogic.cs @@ -0,0 +1,24 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.BusinessLogicsContracts +{ + public interface IProviderLogic + { + List? ReadList(ProviderSearchModel? model); + + ProviderViewModel? ReadElement(ProviderSearchModel model); + + bool Create(ProviderBindingModel model); + + bool Update(ProviderBindingModel model); + + bool Delete(ProviderBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/RestaurantContracts.csproj b/Restaurant/RestaurantContracts/RestaurantContracts.csproj new file mode 100644 index 0000000..65bf8bf --- /dev/null +++ b/Restaurant/RestaurantContracts/RestaurantContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Restaurant/RestaurantContracts/SearchModels/ClientSearchModel.cs b/Restaurant/RestaurantContracts/SearchModels/ClientSearchModel.cs new file mode 100644 index 0000000..a20601d --- /dev/null +++ b/Restaurant/RestaurantContracts/SearchModels/ClientSearchModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.SearchModels +{ + public class ClientSearchModel + { + public int? Id { get; set; } + + public string? FirstName { get; set; } + + public string? LastName { get; set; } + + public string? Number { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/SearchModels/ComponentSearchModel.cs b/Restaurant/RestaurantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..de430ec --- /dev/null +++ b/Restaurant/RestaurantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + + public string? Name { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/SearchModels/OrderSearchModel.cs b/Restaurant/RestaurantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..e52248e --- /dev/null +++ b/Restaurant/RestaurantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + + public DateTime? Date { get; set; } + + public int? ClientId { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/SearchModels/ProductSearchModel.cs b/Restaurant/RestaurantContracts/SearchModels/ProductSearchModel.cs new file mode 100644 index 0000000..528cd56 --- /dev/null +++ b/Restaurant/RestaurantContracts/SearchModels/ProductSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.SearchModels +{ + public class ProductSearchModel + { + public int? Id { get; set; } + + public string? Type { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/SearchModels/ProviderSearchModel.cs b/Restaurant/RestaurantContracts/SearchModels/ProviderSearchModel.cs new file mode 100644 index 0000000..088669a --- /dev/null +++ b/Restaurant/RestaurantContracts/SearchModels/ProviderSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.SearchModels +{ + public class ProviderSearchModel + { + public int? Id { get; set; } + + public string? Name { get; set; } + } +} diff --git a/Restaurant/RestaurantContracts/StoragesContracts/IClientStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IClientStorage.cs new file mode 100644 index 0000000..b619ef4 --- /dev/null +++ b/Restaurant/RestaurantContracts/StoragesContracts/IClientStorage.cs @@ -0,0 +1,21 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.StoragesContracts +{ + public interface IClientStorage + { + List GetFullList(); + List GetFilteredList(ClientSearchModel model); + ClientViewModel? GetElement(ClientSearchModel model); + ClientViewModel? Insert(ClientBindingModel model); + ClientViewModel? Update(ClientBindingModel model); + ClientViewModel? Delete(ClientBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/StoragesContracts/IComponentStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..2b71c88 --- /dev/null +++ b/Restaurant/RestaurantContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.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/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..c48ab20 --- /dev/null +++ b/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,26 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.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/Restaurant/RestaurantContracts/StoragesContracts/IProductStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IProductStorage.cs new file mode 100644 index 0000000..d8279a6 --- /dev/null +++ b/Restaurant/RestaurantContracts/StoragesContracts/IProductStorage.cs @@ -0,0 +1,21 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.StoragesContracts +{ + public interface IProductStorage + { + List GetFullList(); + List GetFilteredList(ProductSearchModel model); + ProductViewModel? GetElement(ProductSearchModel model); + ProductViewModel? Insert(ProductBindingModel model); + ProductViewModel? Update(ProductBindingModel model); + ProductViewModel? Delete(ProductBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/StoragesContracts/IProviderStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IProviderStorage.cs new file mode 100644 index 0000000..cb1be18 --- /dev/null +++ b/Restaurant/RestaurantContracts/StoragesContracts/IProviderStorage.cs @@ -0,0 +1,21 @@ +using RestaurantContracts.BindingModels; +using RestaurantContracts.SearchModels; +using RestaurantContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.StoragesContracts +{ + public interface IProviderStorage + { + List GetFullList(); + List GetFilteredList(ProviderSearchModel model); + ProviderViewModel? GetElement(ProviderSearchModel model); + ProviderViewModel? Insert(ProviderBindingModel model); + ProviderViewModel? Update(ProviderBindingModel model); + ProviderViewModel? Delete(ProviderBindingModel model); + } +} diff --git a/Restaurant/RestaurantContracts/ViewModels/ClientViewModel.cs b/Restaurant/RestaurantContracts/ViewModels/ClientViewModel.cs new file mode 100644 index 0000000..2038b15 --- /dev/null +++ b/Restaurant/RestaurantContracts/ViewModels/ClientViewModel.cs @@ -0,0 +1,24 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.ViewModels +{ + public class ClientViewModel : IClientModel + { + public int Id { get; set; } + + [DisplayName("Имя клиента")] + public string FirstName { get; set; } = string.Empty; + + [DisplayName("Фамилия клиента")] + public string LastName { get; set; } = string.Empty; + + [DisplayName("Номер")] + public string Number { get; set; } = string.Empty; + } +} diff --git a/Restaurant/RestaurantContracts/ViewModels/ComponentViewModel.cs b/Restaurant/RestaurantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..28ffc0f --- /dev/null +++ b/Restaurant/RestaurantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,26 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + + [DisplayName("Название компонента")] + public string Name { get; set; } = string.Empty; + + [DisplayName("Цена")] + public int Price { get; set; } + + [DisplayName("Количество")] + public int Count { get; set; } + + public Dictionary ComponentProviders { get; set; } = new(); + } +} diff --git a/Restaurant/RestaurantContracts/ViewModels/OrderViewModel.cs b/Restaurant/RestaurantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..fbc8248 --- /dev/null +++ b/Restaurant/RestaurantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,32 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер заказа")] + public int Id { get; set; } + + public int ClientId { get; set; } + + [DisplayName("Имя клиента")] + public string ClientFirstName { get; set; } = string.Empty; + + [DisplayName("Фамилия клиента")] + public string ClientLastName { get; set; } = string.Empty; + + [DisplayName("Цена")] + public int Price { get; set; } + + [DisplayName("Дата")] + public DateTime Date { get; set; } + + public Dictionary OrderProducts { get; set; } = new(); + } +} diff --git a/Restaurant/RestaurantContracts/ViewModels/ProductViewModel.cs b/Restaurant/RestaurantContracts/ViewModels/ProductViewModel.cs new file mode 100644 index 0000000..82bc113 --- /dev/null +++ b/Restaurant/RestaurantContracts/ViewModels/ProductViewModel.cs @@ -0,0 +1,26 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.ViewModels +{ + public class ProductViewModel : IProductModel + { + public int Id { get; set; } + + [DisplayName("Вид продукта")] + public string Type { get; set; } = string.Empty; + + [DisplayName("Цена")] + public int Price { get; set; } + + [DisplayName("Количество продуктов")] + public int Count { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + } +} diff --git a/Restaurant/RestaurantContracts/ViewModels/ProviderViewModel.cs b/Restaurant/RestaurantContracts/ViewModels/ProviderViewModel.cs new file mode 100644 index 0000000..8eef42c --- /dev/null +++ b/Restaurant/RestaurantContracts/ViewModels/ProviderViewModel.cs @@ -0,0 +1,21 @@ +using RestaurantDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantContracts.ViewModels +{ + public class ProviderViewModel : IProviderModel + { + public int Id { get; set; } + + [DisplayName("Название поставщика")] + public string Name { get; set; } = string.Empty; + + [DisplayName("Юридический адресс")] + public string Address { get; set; } = string.Empty; + } +} diff --git a/Restaurant/RestaurantDataModels/IId.cs b/Restaurant/RestaurantDataModels/IId.cs new file mode 100644 index 0000000..6044ba7 --- /dev/null +++ b/Restaurant/RestaurantDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace RestaurantDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/Restaurant/RestaurantDataModels/Models/IClientModel.cs b/Restaurant/RestaurantDataModels/Models/IClientModel.cs new file mode 100644 index 0000000..89e7439 --- /dev/null +++ b/Restaurant/RestaurantDataModels/Models/IClientModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantDataModels.Models +{ + public interface IClientModel : IId + { + string FirstName { get; } + + string LastName { get; } + + string Number { get; } + } +} diff --git a/Restaurant/RestaurantDataModels/Models/IComponentModel.cs b/Restaurant/RestaurantDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..645383f --- /dev/null +++ b/Restaurant/RestaurantDataModels/Models/IComponentModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantDataModels.Models +{ + public interface IComponentModel : IId + { + string Name { get; } + + int Price { get; } + + int Count { get; } + + Dictionary ComponentProviders { get; } + } +} diff --git a/Restaurant/RestaurantDataModels/Models/IOrderModel.cs b/Restaurant/RestaurantDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..4724b4f --- /dev/null +++ b/Restaurant/RestaurantDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantDataModels.Models +{ + public interface IOrderModel : IId + { + int ClientId { get; } + + int Price { get; } + + DateTime Date { get; } + + Dictionary OrderProducts { get; } + } +} diff --git a/Restaurant/RestaurantDataModels/Models/IProductModel.cs b/Restaurant/RestaurantDataModels/Models/IProductModel.cs new file mode 100644 index 0000000..d382914 --- /dev/null +++ b/Restaurant/RestaurantDataModels/Models/IProductModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantDataModels.Models +{ + public interface IProductModel : IId + { + string Type { get; } + + int Price { get; } + + int Count { get; } + + Dictionary ProductComponents { get; } + } +} diff --git a/Restaurant/RestaurantDataModels/Models/IProviderModel.cs b/Restaurant/RestaurantDataModels/Models/IProviderModel.cs new file mode 100644 index 0000000..7da9d10 --- /dev/null +++ b/Restaurant/RestaurantDataModels/Models/IProviderModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RestaurantDataModels.Models +{ + public interface IProviderModel : IId + { + string Name { get; } + + string Address { get; } + } +} diff --git a/Restaurant/RestaurantDataModels/RestaurantDataModels.csproj b/Restaurant/RestaurantDataModels/RestaurantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/Restaurant/RestaurantDataModels/RestaurantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/Restaurant/RestaurantView/Form1.Designer.cs b/Restaurant/RestaurantView/Form1.Designer.cs new file mode 100644 index 0000000..5c9a671 --- /dev/null +++ b/Restaurant/RestaurantView/Form1.Designer.cs @@ -0,0 +1,39 @@ +namespace RestaurantView +{ + 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 + } +} \ No newline at end of file diff --git a/Restaurant/RestaurantView/Form1.cs b/Restaurant/RestaurantView/Form1.cs new file mode 100644 index 0000000..4889ae2 --- /dev/null +++ b/Restaurant/RestaurantView/Form1.cs @@ -0,0 +1,10 @@ +namespace RestaurantView +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Restaurant/RestaurantView/Form1.resx b/Restaurant/RestaurantView/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Restaurant/RestaurantView/Form1.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/Restaurant/RestaurantView/Program.cs b/Restaurant/RestaurantView/Program.cs new file mode 100644 index 0000000..b6533e4 --- /dev/null +++ b/Restaurant/RestaurantView/Program.cs @@ -0,0 +1,17 @@ +namespace RestaurantView +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/Restaurant/RestaurantView/RestaurantView.csproj b/Restaurant/RestaurantView/RestaurantView.csproj new file mode 100644 index 0000000..b57c89e --- /dev/null +++ b/Restaurant/RestaurantView/RestaurantView.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + \ No newline at end of file