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