BusinessLogic,

Contracts,
DataModels,
View(пока пусто)
This commit is contained in:
Артём Алейкин 2023-05-02 22:51:41 +04:00
parent f3f6274ff2
commit e52b239c08
44 changed files with 1341 additions and 0 deletions

43
Restaurant/Restaurant.sln Normal file
View File

@ -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

View File

@ -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<ComponentViewModel>? 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("Компонент с таким логином уже есть");
}
}
}
}

View File

@ -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<OrderViewModel>? 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("Заказ с таким номером уже есть");
}
}
}
}

View File

@ -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<ProductViewModel>? 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("Компонент с таким логином уже есть");
}
}
}
}

View File

@ -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<ProviderViewModel>? 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;
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RestaurantContracts\RestaurantContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -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; }
}
}

View File

@ -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<int, (IProviderModel, int)> ComponentProviders { get; set; } = new();
public int Id { get; set; }
}
}

View File

@ -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<int, (IProductModel, int)> OrderProducts { get; set; } = new();
public int Id { get; set; }
}
}

View File

@ -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<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
public int Id { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -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<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -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<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model);
}
}

View File

@ -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<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool Create(OrderBindingModel model);
bool Update(OrderBindingModel model);
bool Delete(OrderBindingModel model);
}
}

View File

@ -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<ProductViewModel>? ReadList(ProductSearchModel? model);
ProductViewModel? ReadElement(ProductSearchModel model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -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<ProviderViewModel>? ReadList(ProviderSearchModel? model);
ProviderViewModel? ReadElement(ProviderSearchModel model);
bool Create(ProviderBindingModel model);
bool Update(ProviderBindingModel model);
bool Delete(ProviderBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RestaurantDataModels\RestaurantDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -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<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model);
}
}

View File

@ -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<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -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<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -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<ProviderViewModel> GetFullList();
List<ProviderViewModel> GetFilteredList(ProviderSearchModel model);
ProviderViewModel? GetElement(ProviderSearchModel model);
ProviderViewModel? Insert(ProviderBindingModel model);
ProviderViewModel? Update(ProviderBindingModel model);
ProviderViewModel? Delete(ProviderBindingModel model);
}
}

View File

@ -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;
}
}

View File

@ -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<int, (IProviderModel, int)> ComponentProviders { get; set; } = new();
}
}

View File

@ -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<int, (IProductModel, int)> OrderProducts { get; set; } = new();
}
}

View File

@ -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<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,7 @@
namespace RestaurantDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -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; }
}
}

View File

@ -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<int, (IProviderModel, int)> ComponentProviders { get; }
}
}

View File

@ -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<int, (IProductModel, int)> OrderProducts { get; }
}
}

View File

@ -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<int, (IComponentModel, int)> ProductComponents { get; }
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,39 @@
namespace RestaurantView
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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
}
}

View File

@ -0,0 +1,10 @@
namespace RestaurantView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,17 @@
namespace RestaurantView
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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());
}
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>