From 8ccddf69ea450c9e1162cf61bd02f96e2dbb6602 Mon Sep 17 00:00:00 2001 From: malimova Date: Thu, 28 Mar 2024 22:21:45 +0400 Subject: [PATCH] new project created --- Confectionery/Confectionery.sln | 6 ++ .../Component.cs | 56 +++++++++++++++++++ .../ConfectioneryDatabaseImplement.csproj | 23 ++++++++ .../ConfectioneryView.csproj | 4 ++ 4 files changed, 89 insertions(+) create mode 100644 Confectionery/ConfectioneryDatabaseImplement/Component.cs create mode 100644 Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj diff --git a/Confectionery/Confectionery.sln b/Confectionery/Confectionery.sln index 16b38b4..16e194e 100644 --- a/Confectionery/Confectionery.sln +++ b/Confectionery/Confectionery.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryView", "Confec EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryFileImplement", "ConfectioneryFileImplement\ConfectioneryFileImplement.csproj", "{BB6D6796-AD42-44BA-9BCC-27D8E1F6D068}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryDatabaseImplement", "ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj", "{F637E749-7A91-4608-908F-4DA0434AB30B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {BB6D6796-AD42-44BA-9BCC-27D8E1F6D068}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB6D6796-AD42-44BA-9BCC-27D8E1F6D068}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB6D6796-AD42-44BA-9BCC-27D8E1F6D068}.Release|Any CPU.Build.0 = Release|Any CPU + {F637E749-7A91-4608-908F-4DA0434AB30B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F637E749-7A91-4608-908F-4DA0434AB30B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F637E749-7A91-4608-908F-4DA0434AB30B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F637E749-7A91-4608-908F-4DA0434AB30B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Confectionery/ConfectioneryDatabaseImplement/Component.cs b/Confectionery/ConfectioneryDatabaseImplement/Component.cs new file mode 100644 index 0000000..a350c35 --- /dev/null +++ b/Confectionery/ConfectioneryDatabaseImplement/Component.cs @@ -0,0 +1,56 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.ViewModels; +using ConfectioneryDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ConfectioneryDatabaseImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + [Required] + public string ComponentName { get; private set; } = string.Empty; + [Required] + public double Cost { get; set; } + [ForeignKey("ComponentId")] + public virtual List PastryComponents { get; set; } = new(); + public static Component? Create(ComponentBindingModel model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public static Component Create(ComponentViewModel model) + { + 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 + }; + } +} \ No newline at end of file diff --git a/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj new file mode 100644 index 0000000..546b9c5 --- /dev/null +++ b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Confectionery/ConfectioneryView/ConfectioneryView.csproj b/Confectionery/ConfectioneryView/ConfectioneryView.csproj index 28b6744..1ca2d77 100644 --- a/Confectionery/ConfectioneryView/ConfectioneryView.csproj +++ b/Confectionery/ConfectioneryView/ConfectioneryView.csproj @@ -9,6 +9,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +