From dfbe5539dd86c5701c09b07a13ad4cf7c107fef5 Mon Sep 17 00:00:00 2001 From: Oleg Shabunov Date: Tue, 6 Feb 2024 23:43:23 +0400 Subject: [PATCH] Contracts --- AutoWorkshop.sln | 6 ++++ .../AutoWorkshopContracts.csproj | 13 ++++++++ .../BindingModels/ComponentBindingModel.cs | 11 +++++++ .../BindingModels/OrderBindingModel.cs | 16 ++++++++++ .../BindingModels/ProductBindingModel.cs | 16 ++++++++++ .../BusinessLogicContracts/IComponentLogic.cs | 16 ++++++++++ .../BusinessLogicContracts/IOrderLogic.cs | 15 +++++++++ .../BusinessLogicContracts/IRepairLogic.cs | 15 +++++++++ .../SearchModels/ComponentSearchModel.cs | 8 +++++ .../SearchModels/OrderSearchModel.cs | 7 ++++ .../SearchModels/RepairSearchModel.cs | 8 +++++ .../StoragesContracts/IComponentStorage.cs | 17 ++++++++++ .../StoragesContracts/IOrderStorage.cs | 16 ++++++++++ .../StoragesContracts/IRepairStorage.cs | 15 +++++++++ .../ViewModels/ComponentViewModel.cs | 16 ++++++++++ .../ViewModels/OrderViewModel.cs | 32 +++++++++++++++++++ .../ViewModels/RepairViewModel.cs | 22 +++++++++++++ AutoWorkshopDataModels/IProductModel.cs | 9 ------ .../{ => Models}/IComponentModel.cs | 2 +- .../{ => Models}/IOrderModel.cs | 0 AutoWorkshopDataModels/Models/IRepairModel.cs | 9 ++++++ 21 files changed, 259 insertions(+), 10 deletions(-) create mode 100644 AutoWorkshopContracts/AutoWorkshopContracts.csproj create mode 100644 AutoWorkshopContracts/BindingModels/ComponentBindingModel.cs create mode 100644 AutoWorkshopContracts/BindingModels/OrderBindingModel.cs create mode 100644 AutoWorkshopContracts/BindingModels/ProductBindingModel.cs create mode 100644 AutoWorkshopContracts/BusinessLogicContracts/IComponentLogic.cs create mode 100644 AutoWorkshopContracts/BusinessLogicContracts/IOrderLogic.cs create mode 100644 AutoWorkshopContracts/BusinessLogicContracts/IRepairLogic.cs create mode 100644 AutoWorkshopContracts/SearchModels/ComponentSearchModel.cs create mode 100644 AutoWorkshopContracts/SearchModels/OrderSearchModel.cs create mode 100644 AutoWorkshopContracts/SearchModels/RepairSearchModel.cs create mode 100644 AutoWorkshopContracts/StoragesContracts/IComponentStorage.cs create mode 100644 AutoWorkshopContracts/StoragesContracts/IOrderStorage.cs create mode 100644 AutoWorkshopContracts/StoragesContracts/IRepairStorage.cs create mode 100644 AutoWorkshopContracts/ViewModels/ComponentViewModel.cs create mode 100644 AutoWorkshopContracts/ViewModels/OrderViewModel.cs create mode 100644 AutoWorkshopContracts/ViewModels/RepairViewModel.cs delete mode 100644 AutoWorkshopDataModels/IProductModel.cs rename AutoWorkshopDataModels/{ => Models}/IComponentModel.cs (74%) rename AutoWorkshopDataModels/{ => Models}/IOrderModel.cs (100%) create mode 100644 AutoWorkshopDataModels/Models/IRepairModel.cs diff --git a/AutoWorkshop.sln b/AutoWorkshop.sln index e719cde..4fc41c1 100644 --- a/AutoWorkshop.sln +++ b/AutoWorkshop.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshop", "AutoWorksho EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopDataModels", "AutoWorkshopDataModels\AutoWorkshopDataModels.csproj", "{D52094D2-A57E-4BAD-B049-3B64065463DA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopContracts", "AutoWorkshopContracts\AutoWorkshopContracts.csproj", "{93CF1C25-57B5-4E95-A394-E01AE440E138}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {D52094D2-A57E-4BAD-B049-3B64065463DA}.Debug|Any CPU.Build.0 = Debug|Any CPU {D52094D2-A57E-4BAD-B049-3B64065463DA}.Release|Any CPU.ActiveCfg = Release|Any CPU {D52094D2-A57E-4BAD-B049-3B64065463DA}.Release|Any CPU.Build.0 = Release|Any CPU + {93CF1C25-57B5-4E95-A394-E01AE440E138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93CF1C25-57B5-4E95-A394-E01AE440E138}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93CF1C25-57B5-4E95-A394-E01AE440E138}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93CF1C25-57B5-4E95-A394-E01AE440E138}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AutoWorkshopContracts/AutoWorkshopContracts.csproj b/AutoWorkshopContracts/AutoWorkshopContracts.csproj new file mode 100644 index 0000000..7c2e15c --- /dev/null +++ b/AutoWorkshopContracts/AutoWorkshopContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/AutoWorkshopContracts/BindingModels/ComponentBindingModel.cs b/AutoWorkshopContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..082e049 --- /dev/null +++ b/AutoWorkshopContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,11 @@ +using AutoWorkshopDataModels.Models; + +namespace AutoWorkshopContracts.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/AutoWorkshopContracts/BindingModels/OrderBindingModel.cs b/AutoWorkshopContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..05da15f --- /dev/null +++ b/AutoWorkshopContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,16 @@ +using AutoWorkshopDataModels.Models; +using AutoWorkshopDataModels.Enums; + +namespace AutoWorkshopContracts.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.Undefined; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} diff --git a/AutoWorkshopContracts/BindingModels/ProductBindingModel.cs b/AutoWorkshopContracts/BindingModels/ProductBindingModel.cs new file mode 100644 index 0000000..cfb103f --- /dev/null +++ b/AutoWorkshopContracts/BindingModels/ProductBindingModel.cs @@ -0,0 +1,16 @@ +using AutoWorkshopDataModels.Models; + +namespace AutoWorkshopContracts.BindingModels +{ + public class RepairBindingModel : IRepairModel + { + public int Id { get; set; } + public string RepairName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary RepairComponents + { + get; + set; + } = new(); + } +} diff --git a/AutoWorkshopContracts/BusinessLogicContracts/IComponentLogic.cs b/AutoWorkshopContracts/BusinessLogicContracts/IComponentLogic.cs new file mode 100644 index 0000000..703ec44 --- /dev/null +++ b/AutoWorkshopContracts/BusinessLogicContracts/IComponentLogic.cs @@ -0,0 +1,16 @@ +using AutoWorkshopContracts.BindingModels; +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.BusinessLogicContracts +{ + 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/AutoWorkshopContracts/BusinessLogicContracts/IOrderLogic.cs b/AutoWorkshopContracts/BusinessLogicContracts/IOrderLogic.cs new file mode 100644 index 0000000..cd42359 --- /dev/null +++ b/AutoWorkshopContracts/BusinessLogicContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using AutoWorkshopContracts.BindingModels; +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.BusinessLogicContracts +{ + 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/AutoWorkshopContracts/BusinessLogicContracts/IRepairLogic.cs b/AutoWorkshopContracts/BusinessLogicContracts/IRepairLogic.cs new file mode 100644 index 0000000..f50173e --- /dev/null +++ b/AutoWorkshopContracts/BusinessLogicContracts/IRepairLogic.cs @@ -0,0 +1,15 @@ +using AutoWorkshopContracts.BindingModels; +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.BusinessLogicContracts +{ + public interface IRepairLogic + { + List? ReadList(RepairSearchModel? model); + RepairViewModel? ReadElement(RepairSearchModel model); + bool Create(RepairBindingModel model); + bool Update(RepairBindingModel model); + bool Delete(RepairBindingModel model); + } +} diff --git a/AutoWorkshopContracts/SearchModels/ComponentSearchModel.cs b/AutoWorkshopContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..2b35114 --- /dev/null +++ b/AutoWorkshopContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,8 @@ +namespace AutoWorkshopContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/AutoWorkshopContracts/SearchModels/OrderSearchModel.cs b/AutoWorkshopContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..a808eae --- /dev/null +++ b/AutoWorkshopContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,7 @@ +namespace AutoWorkshopContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/AutoWorkshopContracts/SearchModels/RepairSearchModel.cs b/AutoWorkshopContracts/SearchModels/RepairSearchModel.cs new file mode 100644 index 0000000..de5d5d2 --- /dev/null +++ b/AutoWorkshopContracts/SearchModels/RepairSearchModel.cs @@ -0,0 +1,8 @@ +namespace AutoWorkshopContracts.SearchModels +{ + public class RepairSearchModel + { + public int? Id { get; set; } + public string? RepairName { get; set; } + } +} diff --git a/AutoWorkshopContracts/StoragesContracts/IComponentStorage.cs b/AutoWorkshopContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..34a6d81 --- /dev/null +++ b/AutoWorkshopContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,17 @@ +using AutoWorkshopContracts.BindingModels; +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.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/AutoWorkshopContracts/StoragesContracts/IOrderStorage.cs b/AutoWorkshopContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..f1d7f29 --- /dev/null +++ b/AutoWorkshopContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using AutoWorkshopContracts.BindingModels; +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.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/AutoWorkshopContracts/StoragesContracts/IRepairStorage.cs b/AutoWorkshopContracts/StoragesContracts/IRepairStorage.cs new file mode 100644 index 0000000..ca1feda --- /dev/null +++ b/AutoWorkshopContracts/StoragesContracts/IRepairStorage.cs @@ -0,0 +1,15 @@ +using AutoWorkshopContracts.SearchModels; +using AutoWorkshopContracts.ViewModels; + +namespace AutoWorkshopContracts.StoragesContracts +{ + public interface IProductStorage + { + List GetFullList(); + List GetFilteredList(RepairSearchModel model); + RepairViewModel? GetElement(RepairSearchModel model); + RepairViewModel? Insert(RepairSearchModel model); + RepairViewModel? Update(RepairSearchModel model); + RepairViewModel? Delete(RepairSearchModel model); + } +} diff --git a/AutoWorkshopContracts/ViewModels/ComponentViewModel.cs b/AutoWorkshopContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..6efe022 --- /dev/null +++ b/AutoWorkshopContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,16 @@ +using AutoWorkshopDataModels.Models; +using System.ComponentModel; + +namespace AutoWorkshopContracts.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/AutoWorkshopContracts/ViewModels/OrderViewModel.cs b/AutoWorkshopContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..670a05b --- /dev/null +++ b/AutoWorkshopContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,32 @@ +using AutoWorkshopDataModels.Enums; +using AutoWorkshopDataModels.Models; +using System.ComponentModel; + +namespace AutoWorkshopContracts.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.Undefined; + + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/AutoWorkshopContracts/ViewModels/RepairViewModel.cs b/AutoWorkshopContracts/ViewModels/RepairViewModel.cs new file mode 100644 index 0000000..5551506 --- /dev/null +++ b/AutoWorkshopContracts/ViewModels/RepairViewModel.cs @@ -0,0 +1,22 @@ +using AutoWorkshopDataModels.Models; +using System.ComponentModel; + +namespace AutoWorkshopContracts.ViewModels +{ + public class RepairViewModel : IRepairModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + + public string RepairName { get; set; } = string.Empty; + [DisplayName("Цена")] + + public double Price { get; set; } + + public Dictionary RepairComponents + { + get; + set; + } = new(); + } +} diff --git a/AutoWorkshopDataModels/IProductModel.cs b/AutoWorkshopDataModels/IProductModel.cs deleted file mode 100644 index 8e080bd..0000000 --- a/AutoWorkshopDataModels/IProductModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace AutoWorkshopDataModels -{ - public interface IProductModel : IId - { - string ProductName { get; } - double Price { get; } - Dictionary ProductComponents { get; } - } -} diff --git a/AutoWorkshopDataModels/IComponentModel.cs b/AutoWorkshopDataModels/Models/IComponentModel.cs similarity index 74% rename from AutoWorkshopDataModels/IComponentModel.cs rename to AutoWorkshopDataModels/Models/IComponentModel.cs index b5ae787..a961915 100644 --- a/AutoWorkshopDataModels/IComponentModel.cs +++ b/AutoWorkshopDataModels/Models/IComponentModel.cs @@ -1,4 +1,4 @@ -namespace AutoWorkshopDataModels +namespace AutoWorkshopDataModels.Models { public interface IComponentModel : IId { diff --git a/AutoWorkshopDataModels/IOrderModel.cs b/AutoWorkshopDataModels/Models/IOrderModel.cs similarity index 100% rename from AutoWorkshopDataModels/IOrderModel.cs rename to AutoWorkshopDataModels/Models/IOrderModel.cs diff --git a/AutoWorkshopDataModels/Models/IRepairModel.cs b/AutoWorkshopDataModels/Models/IRepairModel.cs new file mode 100644 index 0000000..fb2a3d4 --- /dev/null +++ b/AutoWorkshopDataModels/Models/IRepairModel.cs @@ -0,0 +1,9 @@ +namespace AutoWorkshopDataModels.Models +{ + public interface IRepairModel : IId + { + string RepairName { get; } + double Price { get; } + Dictionary RepairComponents { get; } + } +}