diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/MedicationStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/MedicationStorage.cs index 24b89a8..c9e5afa 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/MedicationStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/MedicationStorage.cs @@ -106,28 +106,25 @@ namespace VeterinaryDatabaseImplement.Implements using var context = new VeterinaryDatabase(); return context.Medications - .Select(pet => new ReportDrugsVisitsViewModel() - { - MedicationName = pet.MedicationName, - Drugs = context.Drugs - .Where(drug => drug.DateCreate <= model.DateTo && - drug.DateCreate >= model.DateFrom && drug.Medications - .Select(x => x.MedicationId) - .ToList() - .Contains(pet.Id)) - .Select(drug => drug.GetViewModel) - .ToList(), - Visits = context.Services - .Include(service => service.Visit) - .Where(service => service.Visit!=null&&service.Visit.DateVisit <= model.DateTo && - service.Visit.DateVisit >= model.DateFrom && service.Medications - .Select(x => x.MedicationId) - .ToList() - .Contains(pet.Id)) - .Select(service => service.Visit.GetViewModel) - .ToList(), - }) - .ToList(); + .Select(pet => new ReportDrugsVisitsViewModel() + { + MedicationName = pet.MedicationName, + Drugs = context.Drugs + .Where(drug => drug.DateCreate <= model.DateTo && + drug.DateCreate >= model.DateFrom && drug.Medications.Any(m => m.MedicationId == pet.Id)) + .Select(drug => drug.GetViewModel) + .ToList(), + Visits = context.Services + .Include(service => service.Visit) + .Where(service => service.Visit != null && service.Visit.DateVisit <= model.DateTo && + service.Visit.DateVisit >= model.DateFrom && service.Medications.Any(m => m.MedicationId == pet.Id)) + .Select(service => service.Visit.GetViewModel) + .ToList(), + }) + .ToList(); } + + + } } diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PetStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PetStorage.cs index bc76a54..96c8144 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PetStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PetStorage.cs @@ -49,12 +49,11 @@ namespace VeterinaryDatabaseImplement.Implements using var context = new VeterinaryDatabase(); return context.Pets .Where(pet => model.petsIds == null || model.petsIds.Contains(pet.Id)) - .Include() .Select(pet => new ReportServicesViewModel() { PetName = pet.PetName, Services = context.Services.Include(service => service.Visit).ThenInclude(visit => visit.Pets) - .Where(service => service.Visit!=null&&service.Visit.Pets.Select(x => x.PetId).ToList().Contains(pet.Id)) + .Where(service => service.Visit!=null&&service.Visit.Pets.Any(p => p.PetId == pet.Id)) .Select(service => service.GetViewModel).ToList() }).ToList(); } diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs index 9f3396c..546e2e3 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs @@ -542,7 +542,7 @@ namespace VeterinaryShowDoctorApp.Controllers string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture); string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture); result = APIDoctor.GetRequest> - ($"api/report/getvisitsguidesreport?datefrom={dateFromS}&dateto={dateToS}&doctorid={APIDoctor.Doctor.Id}")!; // переделать + ($"api/report/getdrugsvisitsreport?datefrom={dateFromS}&dateto={dateToS}&doctorid={APIDoctor.Doctor.Id}")!; } catch (Exception ex) @@ -603,7 +603,7 @@ namespace VeterinaryShowDoctorApp.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - APIDoctor.PostRequest("api/report/sendvisitsguidesreporttoemail", new ReportDrugsVisitsBindingModel // поменять + APIDoctor.PostRequest("api/report/senddrugsvisitsreporttoemail", new ReportDrugsVisitsBindingModel { FileName = "C:\\ReportsCourseWork\\pdffile.pdf", DoctorId = APIDoctor.Doctor.Id, diff --git a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs index 120d547..21fec2c 100644 --- a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs @@ -437,8 +437,8 @@ namespace VeterinaryShowOwnerApp.Controllers APIOwner.PostRequest("api/reportowner/createservicelistwordfile", new ReportServicesBindingModel { Pets = pets, - FileName = "C:\\ReportsCourseWork\\wordfile.docx" - }); + FileName = "C:\\Users\\1\\Downloads\\wordfile.docx" + }); Response.Redirect("GetWordFile"); } else @@ -446,23 +446,23 @@ namespace VeterinaryShowOwnerApp.Controllers APIOwner.PostRequest("api/reportowner/createservicelistexcelfile", new ReportServicesBindingModel { Pets = pets, - FileName = "C:\\ReportsCourseWork\\excelfile.xlsx" - }); + FileName = "C:\\Users\\1\\Downloads\\excelfile.xlsx" + }); Response.Redirect("GetExcelFile"); } } - [HttpGet] - public IActionResult GetWordFile() - { - return new PhysicalFileResult("C:\\ReportsCourseWork\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); - } + [HttpGet] + public IActionResult GetWordFile() + { + return new PhysicalFileResult("C:\\Users\\1\\Downloads\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + } - public IActionResult GetExcelFile() - { - return new PhysicalFileResult("C:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - } - [HttpGet] + public IActionResult GetExcelFile() + { + return new PhysicalFileResult("C:\\Users\\1\\Downloads\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } + [HttpGet] public IActionResult Report() { ViewBag.Report = new List();