diff --git a/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs b/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs index 5e65cc7..bb20906 100644 --- a/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs +++ b/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs @@ -690,7 +690,7 @@ View(res); // Строка для визита table += ""; - table += $""; + table += $"{visit.DateVisit}"; table += $"{visit.VisitName}"; table += $""; table += $""; diff --git a/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicAdmin.cs b/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicAdmin.cs index c966636..bf67d27 100644 --- a/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicAdmin.cs +++ b/VetClinic/VetClinicBusinessLogic/BusinessLogics/ReportLogicAdmin.cs @@ -96,36 +96,58 @@ namespace VetClinicBusinessLogic.BusinessLogics List>>>> responseVaccinations = _visitStorage.GetVaccinationsInfo(new MedicineVaccinationsSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, AdminId = model.AdminId!}); List>>>> responseMedicines = - _visitStorage.GetMedicinesInfo(new MedicineVaccinationsSearchModel { DateFrom = model.DateFrom!, DateTo = model.DateTo!, AdminId = model.AdminId! }); + _visitStorage.GetMedicinesInfo(new MedicineVaccinationsSearchModel { AdminId = model.AdminId! }); Dictionary dict = new(); foreach(var visit in responseVaccinations) { - dict.Add(visit.Item1.Id, new()); - dict[visit.Item1.Id].VisitName = visit.Item1.NameVisit; - foreach(var animal in visit.Item2) + if (visit.Item1.DateVisit >= model.DateFrom && visit.Item1.DateVisit <= model.DateTo) { - foreach(var vaccination in animal.Item2) + + + dict.Add(visit.Item1.Id, new()); + dict[visit.Item1.Id].VisitName = visit.Item1.NameVisit; + dict[visit.Item1.Id].DateVisit = visit.Item1.DateVisit; + foreach (var animal in visit.Item2) { - dict[visit.Item1.Id].Vaccinations.Add(vaccination); + foreach (var vaccination in animal.Item2) + { + dict[visit.Item1.Id].Vaccinations.Add(vaccination); + } } } } foreach (var visit in responseMedicines) { - HashSet used = new(); - foreach (var animal in visit.Item2) + if (visit.Item1.DateVisit >= model.DateFrom && visit.Item1.DateVisit <= model.DateTo) { - foreach (var medicine in animal.Item2) + if (!dict.ContainsKey(visit.Item1.Id)) { - if (used.Contains(medicine.Id)) - continue; - dict[visit.Item1.Id].Medicines.Add(medicine); - used.Add(medicine.Id); + dict.Add(visit.Item1.Id, new MedicinesVaccinationsViewModel()); + dict[visit.Item1.Id].VisitName = visit.Item1.NameVisit; + dict[visit.Item1.Id].DateVisit = visit.Item1.DateVisit; + } + HashSet used = new(); + foreach (var animal in visit.Item2) + { + foreach (var medicine in animal.Item2) + { + if (used.Contains(medicine.Id)) + continue; + + dict[visit.Item1.Id].Medicines.Add(medicine); + + used.Add(medicine.Id); + } } } - ans.Add(dict[visit.Item1.Id]); + + + } + foreach (var kvp in dict) + { + ans.Add(kvp.Value); } return ans; } diff --git a/VetClinic/VetClinicBusinessLogic/OfficePackage/AbstractSaveToPdfAdmin.cs b/VetClinic/VetClinicBusinessLogic/OfficePackage/AbstractSaveToPdfAdmin.cs index adf2cfc..fceec9d 100644 --- a/VetClinic/VetClinicBusinessLogic/OfficePackage/AbstractSaveToPdfAdmin.cs +++ b/VetClinic/VetClinicBusinessLogic/OfficePackage/AbstractSaveToPdfAdmin.cs @@ -38,19 +38,11 @@ namespace VetClinicBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { "", visit.VisitName, "", "" }, + Texts = new List { visit.DateVisit.ToString(), visit.VisitName, "", "" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach(var medicine in visit.Medicines) - { - CreateRow(new PdfRowParameters - { - Texts = new List { "", "", "", medicine.MedicineName }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - } + foreach (var vaccination in visit.Vaccinations) { CreateRow(new PdfRowParameters @@ -60,6 +52,15 @@ namespace VetClinicBusinessLogic.OfficePackage ParagraphAlignment = PdfParagraphAlignmentType.Center }); } + foreach (var medicine in visit.Medicines) + { + CreateRow(new PdfRowParameters + { + Texts = new List { "", "", "", medicine.MedicineName }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + } } SavePdf(info); } diff --git a/VetClinic/VetClinicContracts/ViewModels/MedicinesVaccinationsViewModel.cs b/VetClinic/VetClinicContracts/ViewModels/MedicinesVaccinationsViewModel.cs index 2ebbeb8..62bed00 100644 --- a/VetClinic/VetClinicContracts/ViewModels/MedicinesVaccinationsViewModel.cs +++ b/VetClinic/VetClinicContracts/ViewModels/MedicinesVaccinationsViewModel.cs @@ -10,6 +10,7 @@ namespace VetClinicDataBaseImplement.Implements public class MedicinesVaccinationsViewModel { public string VisitName { get; set; } = string.Empty; + public DateTime DateVisit { get; set; } = DateTime.Now; public List Medicines { get; set; } = new(); public List Vaccinations { get; set; } = new(); public DateTime DateFrom { get; set; } = DateTime.Now;