From b960f863f700157a2c1248288021eca5d44171a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Sun, 28 Apr 2024 20:05:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20=D1=80=D0=B5?= =?UTF-8?q?=D1=86=D0=B5=D0=BF=D1=82=D0=B0=20=D0=B8=20=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=B0=20=D0=B2=20=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/RecipeBindingModel.cs | 2 - .../SearchModels/RecipeSearchModel.cs | 1 + .../ViewModels/RecipeViewModel.cs | 3 +- .../Models/IRecipeModel.cs | 2 - .../Models/Medicament.cs | 51 ++++++++++++++++--- .../Models/Recipe.cs | 40 +++++++++++++-- 6 files changed, 83 insertions(+), 16 deletions(-) diff --git a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs index 6f80dc5..28311de 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs @@ -7,7 +7,5 @@ namespace PolyclinicContracts.BindingModels public int Id { get; set; } public int ProceduresCount { get; set; } public string Comment { get; set; } = string.Empty; - public Dictionary ProcedureRecipes { get; set; } = new(); - } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicContracts/SearchModels/RecipeSearchModel.cs b/Polyclinic/PolyclinicContracts/SearchModels/RecipeSearchModel.cs index e5786ef..4105c94 100644 --- a/Polyclinic/PolyclinicContracts/SearchModels/RecipeSearchModel.cs +++ b/Polyclinic/PolyclinicContracts/SearchModels/RecipeSearchModel.cs @@ -3,5 +3,6 @@ public class RecipeSearchModel { public int? Id { get; set; } + public string? Name { get; set; } } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs index b852f50..26d7d31 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs @@ -6,10 +6,11 @@ namespace PolyclinicContracts.ViewModels public class RecipeViewModel : IRecipeModel { public int Id { get; set; } + [DisplayName("Количество процедур")] public int ProceduresCount { get; set; } + [DisplayName("Комментарий")] public string Comment { get; set; } = string.Empty; - public Dictionary ProcedureRecipes { get; set; } = new(); } } diff --git a/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs b/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs index c3b5b1a..f9ba21c 100644 --- a/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs +++ b/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs @@ -4,7 +4,5 @@ { int ProceduresCount { get; set; } string Comment { get; set; } - Dictionary ProcedureRecipes { get; } - } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Medicament.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Medicament.cs index c2244fa..5655caf 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Medicament.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Medicament.cs @@ -1,13 +1,52 @@ -using PolyclinicDataModels.Models; +using PolyclinicContracts.BindingModels; +using PolyclinicContracts.ViewModels; +using PolyclinicDataModels.Models; +using SecuritySystemDatabaseImplement; +using System.ComponentModel.DataAnnotations; namespace PolyclinicDatabaseImplement.Models { public class Medicament : IMedicamentModel { - public string Name => throw new NotImplementedException(); - public string Comment => throw new NotImplementedException(); - public int ProcedureId => throw new NotImplementedException(); - public int SymptomId => throw new NotImplementedException(); - public int Id => throw new NotImplementedException(); + public int Id { get; set; } + + [Required] + public string Name { get; set; } = string.Empty; + + [Required] + public string Comment { get; set; } = string.Empty; + + [Required] + public int ProcedureId { get; set; } + + [Required] + public int SymptomId { get; set; } + + public static Medicament Create(PolyclinicDatabase database, MedicamentBindingModel bindingModel) + { + return new Medicament() + { + Id = bindingModel.Id, + Name = bindingModel.Name, + Comment = bindingModel.Comment, + ProcedureId = bindingModel.ProcedureId, + SymptomId = bindingModel.SymptomId + }; + } + + public void Update(MedicamentBindingModel bindingModel) + { + Name = bindingModel.Name; + Comment = bindingModel.Comment; + } + + public MedicamentViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Comment = Comment, + ProcedureId = ProcedureId, + SymptomId = SymptomId + }; } } diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs index 48ab046..7641782 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs @@ -1,12 +1,42 @@ -using PolyclinicDataModels.Models; +using PolyclinicContracts.BindingModels; +using PolyclinicContracts.ViewModels; +using PolyclinicDataModels.Models; +using SecuritySystemDatabaseImplement; +using System.ComponentModel.DataAnnotations; namespace PolyclinicDatabaseImplement.Models { public class Recipe : IRecipeModel { - public int ProceduresCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public string Comment { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public Dictionary ProcedureRecipes => throw new NotImplementedException(); - public int Id => throw new NotImplementedException(); + public int Id { get; set; } + + [Required] + public int ProceduresCount { get; set; } + + [Required] + public string Comment { get; set; } = string.Empty; + + public static Recipe Create(PolyclinicDatabase database, RecipeBindingModel bindingModel) + { + return new Recipe() + { + Id = bindingModel.Id, + ProceduresCount = bindingModel.ProceduresCount, + Comment = bindingModel.Comment, + }; + } + + public void Update(RecipeBindingModel bindingModel) + { + ProceduresCount = bindingModel.ProceduresCount; + Comment = bindingModel.Comment; + } + + public RecipeViewModel GetViewModel => new() + { + Id = Id, + ProceduresCount = ProceduresCount, + Comment = Comment + }; } }