From 85d51a049353c58f747ff13de1e53d3553d8fd01 Mon Sep 17 00:00:00 2001 From: Efi Date: Wed, 14 Feb 2024 12:57:51 +0400 Subject: [PATCH] Add: MotorPlantContracts and MotorPlantDataModels --- MotorPlant/MotorPlant.sln | 15 ++++++++ .../BindingModels/ComponentBindingModel.cs | 18 +++++++++ .../BindingModels/OrderBindingModel.cs | 27 ++++++++++++++ .../BindingModels/ProductBindingModel.cs | 20 ++++++++++ .../IComponentLogic.cs | 24 ++++++++++++ .../BusinessLogicsContracts/IOrderLogic.cs | 24 ++++++++++++ .../BusinessLogicsContracts/IProductLogic.cs | 24 ++++++++++++ .../MotorPlantContracts.csproj | 9 +++++ .../SearchModels/ComponentSearchModel.cs | 15 ++++++++ .../SearchModels/OrderSearchModel.cs | 13 +++++++ .../SearchModels/ProductSearchModel.cs | 15 ++++++++ .../StoragesContracts/IComponentStorage.cs | 26 +++++++++++++ .../StoragesContracts/IOrderStorage.cs | 26 +++++++++++++ .../StoragesContracts/IProductStorage.cs | 26 +++++++++++++ .../ViewModels/ComponentViewModel.cs | 21 +++++++++++ .../ViewModels/OrderViewModel.cs | 37 +++++++++++++++++++ .../ViewModels/ProductViewModel.cs | 23 ++++++++++++ .../MotorPlantDataModels/Enums/OrderStatus.cs | 21 +++++++++++ MotorPlant/MotorPlantDataModels/IId.cs | 7 ++++ .../Models/IComponentModel.cs | 15 ++++++++ .../Models/IOrderModel.cs | 24 ++++++++++++ .../Models/IProductModel.cs | 18 +++++++++ .../MotorPlantDataModels.csproj | 9 +++++ 23 files changed, 457 insertions(+) create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs create mode 100644 MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/StoragesContracts/IProductStorage.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs create mode 100644 MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs create mode 100644 MotorPlant/MotorPlantDataModels/IId.cs create mode 100644 MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/Models/IProductModel.cs create mode 100644 MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj diff --git a/MotorPlant/MotorPlant.sln b/MotorPlant/MotorPlant.sln index 0fc49da..bccd19f 100644 --- a/MotorPlant/MotorPlant.sln +++ b/MotorPlant/MotorPlant.sln @@ -5,6 +5,13 @@ VisualStudioVersion = 17.9.34607.119 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotorPlantView", "MotorPlantView\MotorPlantView.csproj", "{DA318CE3-82A6-4A80-B2F5-7B5C3FEEDC91}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotorPlantDataModels", "MotorPlantDataModels\MotorPlantDataModels.csproj", "{BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotorPlantContracts", "MotorPlantContracts\MotorPlantContracts.csproj", "{29205916-9BE6-4349-9131-79573670D7DB}" + ProjectSection(ProjectDependencies) = postProject + {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B} = {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +22,14 @@ Global {DA318CE3-82A6-4A80-B2F5-7B5C3FEEDC91}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA318CE3-82A6-4A80-B2F5-7B5C3FEEDC91}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA318CE3-82A6-4A80-B2F5-7B5C3FEEDC91}.Release|Any CPU.Build.0 = Release|Any CPU + {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF6606D4-C24E-4CC6-BA24-E505AB2BCC6B}.Release|Any CPU.Build.0 = Release|Any CPU + {29205916-9BE6-4349-9131-79573670D7DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29205916-9BE6-4349-9131-79573670D7DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29205916-9BE6-4349-9131-79573670D7DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29205916-9BE6-4349-9131-79573670D7DB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..f7710c6 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..d4d1a8e --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AbstractShopDataModels.Enums; +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + + public int ProductId { get; set; } + + public int Count { get; set; } + + public double Sum { get; set; } + + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + public DateTime DateCreate { get; set; } = DateTime.Now; + + public DateTime? DateImplement { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs b/MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs new file mode 100644 index 0000000..31ae477 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BindingModels/ProductBindingModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantDataModels.Models; + +namespace MotorPlantContracts.BindingModels +{ + public class ProductBindingModel : IProductModel + { + public int Id { get; set; } + + public string ProductName { get; set; } = string.Empty; + + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + } +} diff --git a/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..a4eace4 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..9ba10a6 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs new file mode 100644 index 0000000..de8b676 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/BusinessLogicsContracts/IProductLogic.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj b/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj new file mode 100644 index 0000000..27ac386 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/MotorPlantContracts.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..0938ddc --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + + public string? ComponentName { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..227d688 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs b/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs new file mode 100644 index 0000000..0afdd1a --- /dev/null +++ b/MotorPlant/MotorPlantContracts/SearchModels/ProductSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantContracts.SearchModels +{ + public class ProductSearchModel + { + public int? Id { get; set; } + + public string? ProductName { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..0aea0e3 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..7970a2e --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/StoragesContracts/IProductStorage.cs b/MotorPlant/MotorPlantContracts/StoragesContracts/IProductStorage.cs new file mode 100644 index 0000000..14f801a --- /dev/null +++ b/MotorPlant/MotorPlantContracts/StoragesContracts/IProductStorage.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantContracts.BindingModels; +using MotorPlantContracts.SearchModels; +using MotorPlantContracts.ViewModels; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..01e4257 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.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/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..650d82c --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantDataModels.Enums; +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + + public int ProductId { get; set; } + + [DisplayName("Изделие")] + public string ProductName { get; set; } = string.Empty; + + [DisplayName("Количество")] + public int Count { get; set; } + + [DisplayName("Сумма")] + public double Sum { get; set; } + + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs b/MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs new file mode 100644 index 0000000..8e76790 --- /dev/null +++ b/MotorPlant/MotorPlantContracts/ViewModels/ProductViewModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MotorPlantDataModels.Models; +using System.ComponentModel; + +namespace MotorPlantContracts.ViewModels +{ + public class ProductViewModel : IProductModel + { + public int Id { get; set; } + + [DisplayName("Название изделия")] + public string ProductName { get; set; } = string.Empty; + + [DisplayName("Цена")] + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + } +} diff --git a/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs b/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..3fec86a --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Enums/OrderStatus.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + + Принят = 0, + + Выполняется = 1, + + Готов = 2, + + Выдан = 3 + } +} diff --git a/MotorPlant/MotorPlantDataModels/IId.cs b/MotorPlant/MotorPlantDataModels/IId.cs new file mode 100644 index 0000000..d105c90 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace MotorPlantDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs b/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..c949a58 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IComponentModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + + double Cost { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs b/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..5b9f4f4 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IOrderModel.cs @@ -0,0 +1,24 @@ +using MotorPlantDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IOrderModel : IId + { + int ProductId { get; } + + int Count { get; } + + double Sum { get; } + + OrderStatus Status { get; } + + DateTime DateCreate { get; } + + DateTime? DateImplement { get; } + } +} diff --git a/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs b/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs new file mode 100644 index 0000000..2505b83 --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/Models/IProductModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorPlantDataModels.Models +{ + public interface IProductModel : IId + { + string ProductName { get; } + + double Price { get; } + + Dictionary ProductComponents { get; } + } + +} diff --git a/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj b/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/MotorPlant/MotorPlantDataModels/MotorPlantDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + +