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 + }; } }