From cdf691d0787b55e6f361397d6f1fa340b0545f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sun, 12 Feb 2023 19:26:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B-=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D1=81=D1=83=D1=89=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D0=B9=20=D0=B2=20=D1=80=D0=B5=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8E=20=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=D1=89=D0=B0=20=D0=BD=D0=B0=20=D0=BE=D1=81?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B5=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlowerShop/FlowerShop.sln | 14 ++-- .../FlowerShopListImplement.csproj | 14 ++++ .../FlowerShopListImplement/Models/Bouquet.cs | 50 +++++++++++++++ .../Models/Component.cs | 47 ++++++++++++++ .../FlowerShopListImplement/Models/Order.cs | 64 +++++++++++++++++++ 5 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 FlowerShop/FlowerShopListImplement/FlowerShopListImplement.csproj create mode 100644 FlowerShop/FlowerShopListImplement/Models/Bouquet.cs create mode 100644 FlowerShop/FlowerShopListImplement/Models/Component.cs create mode 100644 FlowerShop/FlowerShopListImplement/Models/Order.cs diff --git a/FlowerShop/FlowerShop.sln b/FlowerShop/FlowerShop.sln index 5af9705..db9a6f6 100644 --- a/FlowerShop/FlowerShop.sln +++ b/FlowerShop/FlowerShop.sln @@ -3,13 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShop", "FlowerShop\FlowerShop.csproj", "{086CB019-AA3B-425A-87B0-26662D1F201F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShop", "FlowerShop\FlowerShop.csproj", "{086CB019-AA3B-425A-87B0-26662D1F201F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShopDataModels", "FlowerShopDataModels\FlowerShopDataModels.csproj", "{FDC31847-CB24-4EBD-8CE5-852ED404CEAE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopDataModels", "FlowerShopDataModels\FlowerShopDataModels.csproj", "{FDC31847-CB24-4EBD-8CE5-852ED404CEAE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShopContracts", "FlowerShopContracts\FlowerShopContracts.csproj", "{404B251B-7B48-4648-99B4-7E99EDB05A6C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopContracts", "FlowerShopContracts\FlowerShopContracts.csproj", "{404B251B-7B48-4648-99B4-7E99EDB05A6C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShopBusinessLogic", "FlowerShopBusinessLogic\FlowerShopBusinessLogic.csproj", "{D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopBusinessLogic", "FlowerShopBusinessLogic\FlowerShopBusinessLogic.csproj", "{D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShopListImplement", "FlowerShopListImplement\FlowerShopListImplement.csproj", "{C58840E6-D68D-476E-AB3A-EB13F1740FC8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Release|Any CPU.Build.0 = Release|Any CPU + {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FlowerShop/FlowerShopListImplement/FlowerShopListImplement.csproj b/FlowerShop/FlowerShopListImplement/FlowerShopListImplement.csproj new file mode 100644 index 0000000..ca6fa62 --- /dev/null +++ b/FlowerShop/FlowerShopListImplement/FlowerShopListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/FlowerShop/FlowerShopListImplement/Models/Bouquet.cs b/FlowerShop/FlowerShopListImplement/Models/Bouquet.cs new file mode 100644 index 0000000..c4fbad1 --- /dev/null +++ b/FlowerShop/FlowerShopListImplement/Models/Bouquet.cs @@ -0,0 +1,50 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Models; + +namespace FlowerShopListImplement.Models +{ + public class Bouquet : IBouquetModel + { + public int Id { get; private set; } + public string BouquetName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary BouquetComponents { get; private set; } = new Dictionary(); + + public static Bouquet? Create(BouquetBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Bouquet() + { + Id = model.Id, + BouquetName = model.BouquetName, + Price = model.Price, + BouquetComponents = model.BouquetComponents + }; + } + + public void Update(BouquetBindingModel? model) + { + if (model == null) + { + return; + } + + BouquetName = model.BouquetName; + Price = model.Price; + BouquetComponents = model.BouquetComponents; + } + + public BouquetViewModel GetViewModel => new() + { + Id = Id, + BouquetName = BouquetName, + Price = Price, + BouquetComponents = BouquetComponents + }; + } +} diff --git a/FlowerShop/FlowerShopListImplement/Models/Component.cs b/FlowerShop/FlowerShopListImplement/Models/Component.cs new file mode 100644 index 0000000..e49ccfa --- /dev/null +++ b/FlowerShop/FlowerShopListImplement/Models/Component.cs @@ -0,0 +1,47 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Models; + + +namespace FlowerShopListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + + ComponentName = model.ComponentName; + Cost = model.Cost; + } + + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/FlowerShop/FlowerShopListImplement/Models/Order.cs b/FlowerShop/FlowerShopListImplement/Models/Order.cs new file mode 100644 index 0000000..55daa06 --- /dev/null +++ b/FlowerShop/FlowerShopListImplement/Models/Order.cs @@ -0,0 +1,64 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Enums; +using FlowerShopDataModels.Models; + +namespace FlowerShopListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int BouquetId { 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() + { + Id = model.Id, + BouquetId = model.BouquetId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + + Id = model.Id; + BouquetId = model.BouquetId; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + Id = Id, + BouquetId = BouquetId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} \ No newline at end of file