From d1498c56c524f89a54eb299522dc8f0f447937bc Mon Sep 17 00:00:00 2001 From: MaxKarme <91691525+MaxKarme@users.noreply.github.com> Date: Mon, 13 Feb 2023 19:43:19 +0300 Subject: [PATCH] contracts layer --- .../BindingModels/ComponentBindingModel.cs | 17 +++++++++++ .../BindingModels/OrderBindingModel.cs | 21 ++++++++++++++ .../BindingModels/PizzaBindingModel.cs | 21 ++++++++++++++ .../IComponentLogic.cs | 16 ++++++++++ .../BusinessLogicsContracts/IOrderLogic.cs | 15 ++++++++++ .../BusinessLogicsContracts/IPizzaLogic.cs | 16 ++++++++++ .../PizzeriaContracts.csproj | 13 +++++++++ .../SearchModels/ComponentSearchModel.cs | 15 ++++++++++ .../SearchModels/OrderSearchModel.cs | 13 +++++++++ .../SearchModels/PizzaSearchModel.cs | 14 +++++++++ .../StoragesContracts/IComponentStorage.cs | 17 +++++++++++ .../StoragesContracts/IOrderStorage.cs | 16 ++++++++++ .../StoragesContracts/IPizzaStorage.cs | 16 ++++++++++ .../ViewModels/ComponentViewModel.cs | 20 +++++++++++++ .../ViewModels/OrderViewModel.cs | 29 +++++++++++++++++++ .../ViewModels/PizzaViewModel.cs | 26 +++++++++++++++++ 16 files changed, 285 insertions(+) create mode 100644 Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs create mode 100644 Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs create mode 100644 Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs create mode 100644 Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs create mode 100644 Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj create mode 100644 Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs create mode 100644 Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs create mode 100644 Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs create mode 100644 Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs create mode 100644 Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs create mode 100644 Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs create mode 100644 Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs create mode 100644 Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs create mode 100644 Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs diff --git a/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..fec10c0 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PizzeriaDataModels; + +namespace PizzeriaContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } + +} diff --git a/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..a90b43a --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PizzeriaDataModels; + +namespace PizzeriaContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int PizzaId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } + +} diff --git a/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs new file mode 100644 index 0000000..bcf6cf1 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PizzeriaDataModels; + +namespace PizzeriaContracts.BindingModels +{ + public class PizzaBindingModel : IPizzaModel + { + public int Id { get; set; } + public string PizzaName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary PizzaComponents + { + get; + set; + } = new(); + } +} diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..f114a89 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,16 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } + +} diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..fda864a --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs new file mode 100644 index 0000000..dcf0eb7 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs @@ -0,0 +1,16 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.BusinessLogicsContracts +{ + public interface IPizzaLogic + { + List? ReadList(PizzaSearchModel? model); + PizzaViewModel? ReadElement(PizzaSearchModel model); + bool Create(PizzaBindingModel model); + bool Update(PizzaBindingModel model); + bool Delete(PizzaBindingModel model); + } + +} diff --git a/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj new file mode 100644 index 0000000..f8743a9 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..f0d07ff --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } + +} diff --git a/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..3695879 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs new file mode 100644 index 0000000..d4719e9 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaContracts.SearchModels +{ + public class PizzaSearchModel + { + public int? Id { get; set; } + public string? PizzaName { get; set; } + } +} diff --git a/Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..fd79a39 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,17 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..93b2b2a --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.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/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs new file mode 100644 index 0000000..b17907c --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs @@ -0,0 +1,16 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.StoragesContracts +{ + public interface IPizzaStorage + { + List GetFullList(); + List GetFilteredList(PizzaSearchModel model); + PizzaViewModel? GetElement(PizzaSearchModel model); + PizzaViewModel? Insert(PizzaBindingModel model); + PizzaViewModel? Update(PizzaBindingModel model); + PizzaViewModel? Delete(PizzaBindingModel model); + } +} diff --git a/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..f371a3b --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using PizzeriaDataModels; + +namespace PizzeriaContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } + +} diff --git a/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..02a6c07 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using PizzeriaDataModels; + +namespace PizzeriaContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int PizzaId { get; set; } + [DisplayName("Изделие")] + public string PizzaName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs new file mode 100644 index 0000000..c4bc220 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using PizzeriaDataModels; + + +namespace PizzeriaContracts.ViewModels +{ + public class PizzaViewModel : IPizzaModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string PizzaName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary PizzaComponents + { + get; + set; + } = new(); + } + +}