diff --git a/UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs b/UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs index 930ce2c..d0f02c6 100644 --- a/UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs +++ b/UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs @@ -15,7 +15,7 @@ namespace UniversityBusinessLogic.BusinessLogics { private readonly IDocumentStorage _documentStorage; - public List GetStudentsDiscipline() + public List GetStudentsDiscipline(ReportBindingModel model) { throw new NotImplementedException(); } diff --git a/UniversityContracts/BusinessLogicContracts/IReportProviderLogic.cs b/UniversityContracts/BusinessLogicContracts/IReportProviderLogic.cs index 323f7a3..96131e2 100644 --- a/UniversityContracts/BusinessLogicContracts/IReportProviderLogic.cs +++ b/UniversityContracts/BusinessLogicContracts/IReportProviderLogic.cs @@ -10,7 +10,7 @@ namespace UniversityContracts.BusinessLogicContracts { public interface IReportProviderLogic { - List GetStudentsDiscipline(); + List GetStudentsDiscipline(ReportBindingModel model); List StreamStudentEdStatPeriod(ReportBindingModel model); diff --git a/UniversityContracts/SearchModels/DocumentSearchModel.cs b/UniversityContracts/SearchModels/DocumentSearchModel.cs index 7ae4f19..4304caa 100644 --- a/UniversityContracts/SearchModels/DocumentSearchModel.cs +++ b/UniversityContracts/SearchModels/DocumentSearchModel.cs @@ -11,5 +11,7 @@ namespace UniversityContracts.SearchModels public int? Id { get; set; } public string? Name { get; set; } public int? UserId { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/UniversityDataBaseImplemet/Implements/DocumentStorage.cs b/UniversityDataBaseImplemet/Implements/DocumentStorage.cs index fc8dae7..07ddccd 100644 --- a/UniversityDataBaseImplemet/Implements/DocumentStorage.cs +++ b/UniversityDataBaseImplemet/Implements/DocumentStorage.cs @@ -39,6 +39,34 @@ namespace UniversityDataBaseImplemet.Implements .Select(record => record.GetViewModel) .ToList(); } + else if (model.DateFrom != null && model.DateTo != null && model.UserId.HasValue) // фильтрация для отчета#2 Поставщик + { + return context.Documents + .Where(d => d.Date >= model.DateFrom && d.Date <= model.DateTo) + .Join(context.StudentDocuments, + doc => doc.Id, + studDoc => studDoc.DocumentId, + (doc, studDoc) => new { Document = doc, StudentDocument = studDoc }) + .Join(context.Students, + studDoc => studDoc.StudentDocument.StudentId, + stud => stud.Id, + (studDoc, stud) => new { studDoc.Document, Student = stud }) + .Include(record => record.Student.EducationStatus) + .Join(context.StudentStreams, + studEdu => studEdu.Student.Id, + studStream => studStream.StudentId, + (studEdu, studStream) => new { studEdu.Document, studEdu.Student, studEdu.EducationStatus, StudentStream = studStream }) + .Join(context.Streams, + studStream => studStream.StudentStream.StreamId, + stream => stream.Id, + (studStream, stream) => new { Stream = stream.Name, studStream.Student, studStream.EducationStatus.Name }) + .Select(result => new { + result.Stream, + result.Student, + result.EducationStatus + }) + .ToList(); + } else if (model.UserId.HasValue) { return context.Documents diff --git a/UniversityDataBaseImplemet/Implements/StudentStorage.cs b/UniversityDataBaseImplemet/Implements/StudentStorage.cs index 99cee30..f037278 100644 --- a/UniversityDataBaseImplemet/Implements/StudentStorage.cs +++ b/UniversityDataBaseImplemet/Implements/StudentStorage.cs @@ -51,39 +51,6 @@ namespace UniversityDataBaseImplemet.Implements .Select(record => record.GetViewModel) .ToList(); } - /*else if (model.Disciplines == true) // для отчета#1 Поставщик - { - return context.Students - .Join(context.StudentStreams, student => student.Id, studentStream => studentStream.StudentId, (student, studentStream) => new { Student = student, StreamId = studentStream }) - .Join(context.Streams, studentStream => studentStream.StreamId, stream => stream.Id, (studentStream, stream) => new { Stream = stream }) - .Join(context.Disciplines, record => record.stream.Id, discipline => discipline.StreamId, (record, discipline) => new { record.student, discipline }) - .GroupBy(sd => sd.student) - .Select(g => new { - Student = g.Key.Name, - Disciplines = g.Select(sd => sd.discipline.Name).ToList() - }) - .ToList(); - }*/ - /*else if (model.DateFrom != null && model.DateTo != null) // для отчета#2 Поставщик - { - return context.Students - .Include(record => record.User) - .Include(record => record.EducationStatus) - .Join(context.StudentStreams, - student => student.Id, - studentStream => studentStream.StudentId, - (student, studentStream) => new { Student = student, StreamId = studentStream }) - .Join(context.Streams, - studentStream => studentStream.StreamId, - stream => stream.Id, - (studentStream, stream) => new { Stream = stream }) - .Select(result => new - { - Stream = result.Stream, - Students = result.Select(record => (record.Student, record.EducationStatus)).ToList() - }) - .ToList(); - }*/ else { return new();