From cdcdfa9709286d5bf9763955b97d8b44a35054cc Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 10 Feb 2023 14:25:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81=D0=BE=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlacksmithWorkshop/BlacksmithWorkshop.sln | 12 ++- .../BlacksmithWorkshopListImplement.csproj | 9 +++ .../Models/Article.cs | 63 +++++++++++++++ .../Models/Order.cs | 77 +++++++++++++++++++ .../Models/WorkPiece.cs | 58 ++++++++++++++ 5 files changed, 216 insertions(+), 3 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Article.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/WorkPiece.cs diff --git a/BlacksmithWorkshop/BlacksmithWorkshop.sln b/BlacksmithWorkshop/BlacksmithWorkshop.sln index 6609d26..1c793e7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop.sln +++ b/BlacksmithWorkshop/BlacksmithWorkshop.sln @@ -5,11 +5,13 @@ VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshop", "BlacksmithWorkshop\BlacksmithWorkshop.csproj", "{FEF2DC94-D11E-4D77-9F59-5B89A09D0996}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopDataModels", "BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj", "{842406BF-3B58-4F5C-A4EB-AAB84F66ABEC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopDataModels", "BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj", "{842406BF-3B58-4F5C-A4EB-AAB84F66ABEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopContracts", "BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj", "{EBDA1A18-346F-4427-BC86-ED41C062A75B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopContracts", "BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj", "{EBDA1A18-346F-4427-BC86-ED41C062A75B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopBusinessLogic", "BlacksmithWorkshopBusinessLogic\BlacksmithWorkshopBusinessLogic.csproj", "{B3C97222-2894-4D74-B0D7-B3BEB347081D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopBusinessLogic", "BlacksmithWorkshopBusinessLogic\BlacksmithWorkshopBusinessLogic.csproj", "{B3C97222-2894-4D74-B0D7-B3BEB347081D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopListImplement", "BlacksmithWorkshopListImplement\BlacksmithWorkshopListImplement.csproj", "{2942D468-0C3B-4B8D-A15F-184F5D7C969A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {B3C97222-2894-4D74-B0D7-B3BEB347081D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3C97222-2894-4D74-B0D7-B3BEB347081D}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3C97222-2894-4D74-B0D7-B3BEB347081D}.Release|Any CPU.Build.0 = Release|Any CPU + {2942D468-0C3B-4B8D-A15F-184F5D7C969A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2942D468-0C3B-4B8D-A15F-184F5D7C969A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2942D468-0C3B-4B8D-A15F-184F5D7C969A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2942D468-0C3B-4B8D-A15F-184F5D7C969A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Article.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Article.cs new file mode 100644 index 0000000..3fb18b4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Article.cs @@ -0,0 +1,63 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + //класс реализующий интерфейс модели изделия + public class Article : IArticleModel + { + //методы set делаем приватным, чтобы исключить неразрешённые манипуляции + public int Id { get; private set; } + + public string ArticleName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public Dictionary ArticleWorkPiece { get; private set; } = new Dictionary(); + + //метод для создания объекта от класса-компонента на основе класса-BindingModel + public static Article? Create(ArticleBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Article() + { + Id = model.Id, + ArticleName = model.ArticleName, + Price = model.Price, + ArticleWorkPiece = model.ArticleWorkPiece + }; + } + + //метод изменения существующего объекта + public void Update(ArticleBindingModel? model) + { + if (model == null) + { + return; + } + + ArticleName = model.ArticleName; + Price = model.Price; + ArticleWorkPiece = model.ArticleWorkPiece; + } + + //метод для создания объекта класса ViewModel на основе данных объекта класса-компонента + public ArticleViewModel GetViewModel() => new() + { + Id = Id, + ArticleName = ArticleName, + Price = Price, + ArticleWorkPiece = ArticleWorkPiece + }; + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs new file mode 100644 index 0000000..13e02d6 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs @@ -0,0 +1,77 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Enums; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.PortableExecutable; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + //класс, реализующий интерфейс модели заказа + public class Order : IOrderModel + { + //методы set сделали приватными, чтобы исключить неразрешённые манипуляции + public int Id { get; private set; } + + public int ArticleId { get; private set; } + + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; private set; } + + public DateTime DateCreate { get; private set; } + + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Order() + { + ArticleId = model.ArticleId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, //а надо ли? + DateImplement = model.DateImplement //а надо ли? + }; + } + + //метод изменения существующего объекта + public void Update(OrderBindingModel? model) + { + if(model == null) + { + return; + } + + ArticleId = model.ArticleId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; //а надо ли? + DateImplement = model.DateImplement; //а надо ли? + } + + //метод для создания объекта класса ViewModel на основе данных объекта класса-компонента + public OrderViewModel GetViewModel() => new() + { + ArticleId = ArticleId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, //а надо ли? + DateImplement = DateImplement //а надо ли? + }; + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/WorkPiece.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/WorkPiece.cs new file mode 100644 index 0000000..fdd1df1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/WorkPiece.cs @@ -0,0 +1,58 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + //реализация интерфейса модели заготовки + public class WorkPiece : IWorkPieceModel + { + //методы set делаем приватным, чтобы исключить неразрешённые манипуляции + public int Id { get; private set; } + + public string WorkPieceName { get; private set; } = string.Empty; + + public double Cost { get; private set; } + + //метод для создания объекта от класса-компонента на основе класса-BindingModel + public static WorkPiece? Create(WorkPieceBindingModel? model) + { + if(model == null) + { + return null; + } + + return new WorkPiece() + { + Id = model.Id, + WorkPieceName = model.WorkPieceName, + Cost = model.Cost + }; + } + + //метод изменения существующего объекта + public void Update(WorkPieceBindingModel? model) + { + if(model == null) + { + return; + } + + WorkPieceName = model.WorkPieceName; + Cost = model.Cost; + } + + //метод для создания объекта класса ViewModel на основе данных объекта класса-компонента + public WorkPieceViewModel GetViewModel => new() + { + Id = Id, + WorkPieceName = WorkPieceName, + Cost = Cost + }; + } +}