From 0e1ca068bda1bed8ad941584a84912b6bbc20c22 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: Wed, 1 May 2024 10:33:00 +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=B4=D0=B0=D1=82=D1=83=20=D0=B2=20=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8E=20=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B0=20=D1=83=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80=D1=8B,=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=D1=89=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=B0=D1=82=D1=83=20=D0=B2=20=D0=B4=D0=B8=D0=B0=D0=B3?= =?UTF-8?q?=D0=BD=D0=BE=D0=B7=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/DiagnoseBindingModel.cs | 2 ++ .../BindingModels/ProcedureBindingModel.cs | 4 ++-- .../SearchModels/DiagnoseSearchModel.cs | 2 ++ .../SearchModels/ProcedureSearchModel.cs | 1 + .../ViewModels/DiagnoseViewModel.cs | 7 +++++++ .../ViewModels/ProcedureViewModel.cs | 4 ++-- .../PolyclinicDataModels/Models/IDiagnoseModel.cs | 2 ++ .../PolyclinicDataModels/Models/IProcedureModel.cs | 4 ++-- .../Implements/ProcedureStorage.cs | 10 ++++++++-- .../PolyclinicDatabaseImplement/Models/Diagnose.cs | 12 ++++++++++-- .../PolyclinicDatabaseImplement/Models/Procedure.cs | 13 +++++++------ 11 files changed, 45 insertions(+), 16 deletions(-) diff --git a/Polyclinic/PolyclinicContracts/BindingModels/DiagnoseBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/DiagnoseBindingModel.cs index b406e97..01877ac 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/DiagnoseBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/DiagnoseBindingModel.cs @@ -8,5 +8,7 @@ namespace PolyclinicContracts.BindingModels public string Comment { get; set; } = string.Empty; public int UserId { get; set; } public int Id { get; set; } + public DateTime DateStartDiagnose { get; } + public DateTime? DateStopDiagnose { get; } } } diff --git a/Polyclinic/PolyclinicContracts/BindingModels/ProcedureBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/ProcedureBindingModel.cs index d96adcf..fefd338 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/ProcedureBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/ProcedureBindingModel.cs @@ -8,8 +8,8 @@ namespace PolyclinicContracts.BindingModels public int UserId { get; set; } public string Name { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty; - public DateTime From { get; set; } = DateTime.Now; - public DateTime? To { get; set; } + public DateTime DateStartProcedure { get; set; } = DateTime.Now; + public DateTime? DateStopProcedure { get; set; } } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicContracts/SearchModels/DiagnoseSearchModel.cs b/Polyclinic/PolyclinicContracts/SearchModels/DiagnoseSearchModel.cs index cc2711c..1ccfb4c 100644 --- a/Polyclinic/PolyclinicContracts/SearchModels/DiagnoseSearchModel.cs +++ b/Polyclinic/PolyclinicContracts/SearchModels/DiagnoseSearchModel.cs @@ -5,5 +5,7 @@ public int? Id { get; set; } public string? Name { get; set; } public int? UserId { get; set; } + public DateTime? From { get; } + public DateTime? To { get; } } } diff --git a/Polyclinic/PolyclinicContracts/SearchModels/ProcedureSearchModel.cs b/Polyclinic/PolyclinicContracts/SearchModels/ProcedureSearchModel.cs index 9e01ee8..03d172d 100644 --- a/Polyclinic/PolyclinicContracts/SearchModels/ProcedureSearchModel.cs +++ b/Polyclinic/PolyclinicContracts/SearchModels/ProcedureSearchModel.cs @@ -3,6 +3,7 @@ public class ProcedureSearchModel { public int? Id { get; set; } + public int? UserId { get; set; } public string? Name { get; set; } public DateTime? From { get; set; } public DateTime? To { get; set; } diff --git a/Polyclinic/PolyclinicContracts/ViewModels/DiagnoseViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/DiagnoseViewModel.cs index d3455a4..7231a42 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/DiagnoseViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/DiagnoseViewModel.cs @@ -7,8 +7,15 @@ namespace PolyclinicContracts.ViewModels { [DisplayName("Название")] public string Name { get; set; } = string.Empty; + [DisplayName("Комментарий")] public string Comment { get; set; } = string.Empty; + + [DisplayName("Дата 'от'")] + public DateTime DateStartDiagnose { get; set; } = DateTime.Now; + + [DisplayName("Дата 'до'")] + public DateTime? DateStopDiagnose { get; set; } = DateTime.Now; public int UserId { get; set; } public int Id { get; set; } } diff --git a/Polyclinic/PolyclinicContracts/ViewModels/ProcedureViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/ProcedureViewModel.cs index 7adb600..e495dd5 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/ProcedureViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/ProcedureViewModel.cs @@ -15,9 +15,9 @@ namespace PolyclinicContracts.ViewModels public string Comment { get; set; } = string.Empty; [DisplayName("Дата 'от'")] - public DateTime From { get; set; } = DateTime.Now; + public DateTime DateStartProcedure { get; set; } = DateTime.Now; [DisplayName("Дата 'до'")] - public DateTime? To { get; set; } = DateTime.Now; + public DateTime? DateStopProcedure { get; set; } = DateTime.Now; } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicDataModels/Models/IDiagnoseModel.cs b/Polyclinic/PolyclinicDataModels/Models/IDiagnoseModel.cs index a68bf2d..bdb1165 100644 --- a/Polyclinic/PolyclinicDataModels/Models/IDiagnoseModel.cs +++ b/Polyclinic/PolyclinicDataModels/Models/IDiagnoseModel.cs @@ -5,5 +5,7 @@ string Name { get; } string Comment { get; } int UserId { get; } + DateTime DateStartDiagnose { get; } + DateTime? DateStopDiagnose { get; } } } diff --git a/Polyclinic/PolyclinicDataModels/Models/IProcedureModel.cs b/Polyclinic/PolyclinicDataModels/Models/IProcedureModel.cs index d2c3d7d..d40c210 100644 --- a/Polyclinic/PolyclinicDataModels/Models/IProcedureModel.cs +++ b/Polyclinic/PolyclinicDataModels/Models/IProcedureModel.cs @@ -5,7 +5,7 @@ string Name { get; } string Comment { get; } int UserId { get; } - DateTime From { get; } - DateTime? To { get; } + DateTime DateStartProcedure { get; } + DateTime? DateStopProcedure { get; } } } \ No newline at end of file diff --git a/Polyclinic/PolyclinicDatabaseImplement/Implements/ProcedureStorage.cs b/Polyclinic/PolyclinicDatabaseImplement/Implements/ProcedureStorage.cs index 63002db..c596909 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Implements/ProcedureStorage.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Implements/ProcedureStorage.cs @@ -14,20 +14,25 @@ namespace PolyclinicDatabaseImplement.Implements { using var database = new PolyclinicDatabase(); return database.Procedures - .ToList() + .Include(p => p.User) .Select(x => x.GetViewModel) .ToList(); } public List GetFilteredList(ProcedureSearchModel model) { + if (!model.Id.HasValue && !model.From.HasValue && !model.To.HasValue && !model.UserId.HasValue) + { + return new(); + } if (string.IsNullOrEmpty(model.Name)) { return new(); } using var database = new PolyclinicDatabase(); return database.Procedures - .Where(x => x.Name == model.Name) + .Where(x => x.Id == model.Id || x.Name == model.Name || x.DateStartProcedure <= model.To) + .Include(p => p.User) .Select(x => x.GetViewModel) .ToList(); } @@ -41,6 +46,7 @@ namespace PolyclinicDatabaseImplement.Implements } using var database = new PolyclinicDatabase(); return database.Procedures + .Include(p => p.User) .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Diagnose.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Diagnose.cs index 3366fa2..526d6e1 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Diagnose.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Diagnose.cs @@ -13,6 +13,10 @@ namespace PolyclinicDatabaseImplement.Models public string Comment { get; set; } = string.Empty; [Required] public int UserId { get; set; } + + [Required] + public DateTime DateStartDiagnose { get; set; } = DateTime.Now; + public DateTime? DateStopDiagnose { get; set; } public int Id { get; set; } public virtual User User { get; set; } = new(); @@ -27,7 +31,9 @@ namespace PolyclinicDatabaseImplement.Models Name = model.Name, Comment = model.Comment, UserId = model.UserId, - Id = model.Id + Id = model.Id, + DateStartDiagnose = model.DateStartDiagnose, + DateStopDiagnose = model.DateStopDiagnose, }; } @@ -46,7 +52,9 @@ namespace PolyclinicDatabaseImplement.Models Name = Name, Comment = Comment, UserId = UserId, - Id = Id + Id = Id, + DateStartDiagnose = DateStartDiagnose, + DateStopDiagnose = DateStopDiagnose, }; } } diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs index 2ade946..bbf91e7 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Procedure.cs @@ -17,8 +17,9 @@ namespace PolyclinicDatabaseImplement.Models public string Name { get; set; } = string.Empty; [Required] - public DateTime From { get; set; } = DateTime.Now; - public DateTime? To { get; set; } + public DateTime DateStartProcedure { get; set; } = DateTime.Now; + public DateTime? DateStopProcedure { get; set; } + public virtual User User { get; set; } = new(); [Required] public string Comment { get; set; } = string.Empty; @@ -31,8 +32,8 @@ namespace PolyclinicDatabaseImplement.Models UserId = bindingModel.UserId, Name = bindingModel.Name, Comment = bindingModel.Comment, - From = bindingModel.From, - To = bindingModel.To, + DateStartProcedure = bindingModel.DateStartProcedure, + DateStopProcedure = bindingModel.DateStopProcedure, }; } @@ -48,8 +49,8 @@ namespace PolyclinicDatabaseImplement.Models Name = Name, UserId = UserId, Comment = Comment, - From = From, - To = To, + DateStartProcedure = DateStartProcedure, + DateStopProcedure = DateStopProcedure, }; } }