From 99ca054c53c0880f92bfbff0ec30cb66d55116b1 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Thu, 2 May 2024 19:35:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=89=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogicPharmacist.cs | 4 +--- ...ingModel.cs => VisitsGuidesBindingModel.cs} | 4 +++- .../SearchModels/MedicineSearchModel.cs | 1 - .../SearchModels/ServiceSearchModel.cs | 1 - ...earchModel.cs => VisitGuidesSearchModel.cs} | 4 +++- .../StoragesContracts/IMedicineStorage.cs | 4 ++-- .../StoragesContracts/IServiceStorage.cs | 2 +- .../ViewModels/VisitsGuidesViewModel.cs | 18 ++++++++++++++++++ .../Implements/MedicineStorage.cs | 10 +++++----- .../Implements/ServiceStorage.cs | 3 +-- .../Implements/VisitsGuidesViewModel.cs | 4 ++-- 11 files changed, 36 insertions(+), 19 deletions(-) rename VetClinic/VetClinicContracts/BindingModels/{VisistsGuidesBindingModel.cs => VisitsGuidesBindingModel.cs} (67%) rename VetClinic/VetClinicContracts/SearchModels/{VisitServicesSearchModel.cs => VisitGuidesSearchModel.cs} (64%) create mode 100644 VetClinic/VetClinicContracts/ViewModels/VisitsGuidesViewModel.cs diff --git a/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicPharmacist.cs b/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicPharmacist.cs index e94c885..407b670 100644 --- a/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicPharmacist.cs +++ b/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicPharmacist.cs @@ -17,15 +17,13 @@ namespace VetClinicBusinessLogic.BusinessLogics { private readonly IServiceStorage _serviceStorage; private readonly IMedicineStorage _medicineStorage; - private readonly IAnimalStorage _animalStorage; private readonly AbstractSaveToExcelPharmacist _saveToExcel; private readonly AbstractSaveToWordPharmacist _saveToWord; - public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage, IAnimalStorage animalStorage, + public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage, AbstractSaveToExcelPharmacist saveToExcel, AbstractSaveToWordPharmacist saveToWord) { _serviceStorage = serviceStorage; _medicineStorage = medicineStorage; - _animalStorage = animalStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; } diff --git a/VetClinic/VetClinicContracts/BindingModels/VisistsGuidesBindingModel.cs b/VetClinic/VetClinicContracts/BindingModels/VisitsGuidesBindingModel.cs similarity index 67% rename from VetClinic/VetClinicContracts/BindingModels/VisistsGuidesBindingModel.cs rename to VetClinic/VetClinicContracts/BindingModels/VisitsGuidesBindingModel.cs index b32384d..33d5ed9 100644 --- a/VetClinic/VetClinicContracts/BindingModels/VisistsGuidesBindingModel.cs +++ b/VetClinic/VetClinicContracts/BindingModels/VisitsGuidesBindingModel.cs @@ -6,9 +6,11 @@ using System.Threading.Tasks; namespace VetClinicContracts.BindingModels { - public class VisistsGuidesBindingModel + public class VisitsGuidesBindingModel { public string FileName { get; set; } = string.Empty; public List Medicines { get; set; } = new(); + DateTime DateFrom { get; set; } = DateTime.Now; + DateTime DateTo { get; set; } = DateTime.Now; } } diff --git a/VetClinic/VetClinicContracts/SearchModels/MedicineSearchModel.cs b/VetClinic/VetClinicContracts/SearchModels/MedicineSearchModel.cs index 85f673e..c7caf8e 100644 --- a/VetClinic/VetClinicContracts/SearchModels/MedicineSearchModel.cs +++ b/VetClinic/VetClinicContracts/SearchModels/MedicineSearchModel.cs @@ -11,6 +11,5 @@ namespace VetClinicContracts.SearchModels public int? Id { get; set; } public string? MedicineName { get; set; } = string.Empty; public int? PharmacistId { get; set; } - public int? ServiceId { get; set; } } } diff --git a/VetClinic/VetClinicContracts/SearchModels/ServiceSearchModel.cs b/VetClinic/VetClinicContracts/SearchModels/ServiceSearchModel.cs index 8e00f3a..edf5d11 100644 --- a/VetClinic/VetClinicContracts/SearchModels/ServiceSearchModel.cs +++ b/VetClinic/VetClinicContracts/SearchModels/ServiceSearchModel.cs @@ -11,6 +11,5 @@ namespace VetClinicContracts.SearchModels public int? Id { get; set; } public string? ServiceName { get; set; } = string.Empty; public int? PharmacistId { get; set; } - public int? MedicineId { get; set; } } } diff --git a/VetClinic/VetClinicContracts/SearchModels/VisitServicesSearchModel.cs b/VetClinic/VetClinicContracts/SearchModels/VisitGuidesSearchModel.cs similarity index 64% rename from VetClinic/VetClinicContracts/SearchModels/VisitServicesSearchModel.cs rename to VetClinic/VetClinicContracts/SearchModels/VisitGuidesSearchModel.cs index 783cb35..c25ab26 100644 --- a/VetClinic/VetClinicContracts/SearchModels/VisitServicesSearchModel.cs +++ b/VetClinic/VetClinicContracts/SearchModels/VisitGuidesSearchModel.cs @@ -6,8 +6,10 @@ using System.Threading.Tasks; namespace VetClinicContracts.SearchModels { - public class VisitServicesSearchModel + public class VisitGuidesSearchModel { public List? medicinesIds { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/VetClinic/VetClinicContracts/StoragesContracts/IMedicineStorage.cs b/VetClinic/VetClinicContracts/StoragesContracts/IMedicineStorage.cs index d638c77..795dcd9 100644 --- a/VetClinic/VetClinicContracts/StoragesContracts/IMedicineStorage.cs +++ b/VetClinic/VetClinicContracts/StoragesContracts/IMedicineStorage.cs @@ -17,8 +17,8 @@ namespace VetClinicContracts.StoragesContracts MedicineViewModel? Insert(MedicineBindingModel model); MedicineViewModel? Update(MedicineBindingModel model); MedicineViewModel? Delete(MedicineBindingModel model); - public List>>>> GetGuidancesInfo(VisitServicesSearchModel model); - public List>>>> GetVisitsInfo(VisitServicesSearchModel model); + List>>>> GetGuidancesInfo(VisitGuidesSearchModel model); + List>>>> GetVisitsInfo(VisitGuidesSearchModel model); } } diff --git a/VetClinic/VetClinicContracts/StoragesContracts/IServiceStorage.cs b/VetClinic/VetClinicContracts/StoragesContracts/IServiceStorage.cs index 7c9f75f..fa178c3 100644 --- a/VetClinic/VetClinicContracts/StoragesContracts/IServiceStorage.cs +++ b/VetClinic/VetClinicContracts/StoragesContracts/IServiceStorage.cs @@ -13,7 +13,7 @@ namespace VetClinicContracts.StoragesContracts { List GetFullList(); List GetFilteredList(ServiceSearchModel model); - public List>>>> GetReportInfo(ListAnimalsSearchModel model); + List>>>> GetReportInfo(ListAnimalsSearchModel model); ServiceViewModel? GetElement(ServiceSearchModel model); ServiceViewModel? Insert(ServiceBindingModel model); ServiceViewModel? Update(ServiceBindingModel model); diff --git a/VetClinic/VetClinicContracts/ViewModels/VisitsGuidesViewModel.cs b/VetClinic/VetClinicContracts/ViewModels/VisitsGuidesViewModel.cs new file mode 100644 index 0000000..f6235fb --- /dev/null +++ b/VetClinic/VetClinicContracts/ViewModels/VisitsGuidesViewModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VetClinicContracts.ViewModels; + +namespace VetClinicDataBaseImplement.Implements +{ + public class VisitsGuidesViewModel + { + public string MedicineName { get; set; } = string.Empty; + public List Visits { get; set; } = new(); + public List Guidances { get; set; } = new(); + public DateTime DateFrom { get; set; } = DateTime.Now; + public DateTime DateTo { get; set; } = DateTime.Now; + } +} diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs index e3a3073..e5932ab 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs @@ -29,11 +29,11 @@ namespace VetClinicDataBaseImplement.Implements .ThenInclude(x => x.Animal).Include(x => x.Services).ThenInclude(x => x.Service) .Where(x => (string.IsNullOrEmpty(model.MedicineName) || x.MedicineName.Contains(model.MedicineName)) && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId) - && (!model.ServiceId.HasValue || x.Services.Select(x => x.ServiceId).ToList().Contains(model.ServiceId.Value))) + ) .Select(x => x.GetViewModel) .ToList(); } - public List>>>> GetGuidancesInfo(VisitServicesSearchModel model) + public List>>>> GetGuidancesInfo(VisitGuidesSearchModel model) { if (model.medicinesIds == null) { @@ -46,11 +46,11 @@ namespace VetClinicDataBaseImplement.Implements context.ServiceMedicines.Include(service => service.Service) .Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId). Select(service => new Tuple>(service.Service.GetViewModel, - context.Guidances.Include(x => x.Service).Where(x => x.ServiceId == service.ServiceId). + context.Guidances.Include(x => x.Service).Where(x => x.ServiceId == service.ServiceId && x.Date >= model.DateFrom && x.Date <= model.DateTo). Select(x => x.GetViewModel).ToList())).ToList())).ToList(); } - public List>>>> GetVisitsInfo(VisitServicesSearchModel model) + public List>>>> GetVisitsInfo(VisitGuidesSearchModel model) { if (model.medicinesIds == null) { @@ -63,7 +63,7 @@ namespace VetClinicDataBaseImplement.Implements context.ServiceMedicines.Include(service => service.Service) .Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId). Select(service => new Tuple>(service.Service.GetViewModel, - context.ServiceVisits.Include(x => x.Visit).Where(x => x.ServiceId == service.ServiceId). + context.ServiceVisits.Include(x => x.Visit).Where(x => x.ServiceId == service.ServiceId && x.Visit.DateVisit >= model.DateFrom && x.Visit.DateVisit <= model.DateTo). Select(x => x.Visit.GetViewModel).ToList())).ToList())).ToList(); } diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/ServiceStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/ServiceStorage.cs index 025f0d4..1f8e549 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/ServiceStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/ServiceStorage.cs @@ -32,8 +32,7 @@ namespace VetClinicDataBaseImplement.Implements .Include(x => x.Medicines) .ThenInclude(x => x.Medicine) .Where(x => (string.IsNullOrEmpty(model.ServiceName) || x.ServiceName.Contains(model.ServiceName)) - && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId) - && (!model.MedicineId.HasValue || x.Medicines.Select(x => x.MedicineId).ToList().Contains(model.MedicineId.Value))) + && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId)) .ToList() .Select(x => x.GetViewModel) .ToList(); diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/VisitsGuidesViewModel.cs b/VetClinic/VetClinicDataBaseImplement/Implements/VisitsGuidesViewModel.cs index c8c3057..549f058 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/VisitsGuidesViewModel.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/VisitsGuidesViewModel.cs @@ -10,7 +10,7 @@ namespace VetClinicDataBaseImplement.Implements public class VisitsGuidesViewModel { string MedicineName { get; set; } = string.Empty; - List Visits { get; set; } - List Guidances { get; set; } + List Visits { get; set; } = new(); + List Guidances { get; set; } = new(); } }