diff --git a/UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs b/UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs index 9290c29..4762fad 100644 --- a/UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs +++ b/UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs @@ -9,6 +9,9 @@ using UniversityContracts.ViewModels; using UniversityContracts.SearchModels; using UniversityContracts.StoragesContracts; using UniversityBusinessLogic.OfficePackage; +using System.Reflection; +using System.Net; +using System.Reflection.Metadata; namespace UniversityBusinessLogic.BusinessLogics { @@ -45,32 +48,49 @@ namespace UniversityBusinessLogic.BusinessLogics _saveToPdf = saveToPdf; } - public List GetDisciplineReport(List students) + public List GetDiscipline(ReportBindingModel model) { - throw new NotImplementedException(); - } - - public List GetStreamEdStat(ReportBindingModel model) - { - - var result = _streamStorage - .GetFilteredList(new StreamSearchModel { UserId = model.UserId }) - .Select(stream => new ReportStreamStudentEdStatPeriodViewModel + var result = _streamStorage.GetFilteredList(new StreamSearchModel { Id = _disciplineStorage.GetElement(new DisciplineSearchModel { Name = model.DisciplineName })?.StreamId }) + .Select(stream => new ReportDisciplineViewModel { - StreamName = stream.Name, - StudentEdStatus = stream.StudentStream + DisciplineName = model.DisciplineName, + StudentEdStatus = stream.StudentStream .Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel { UserId = model.UserId, + DateFrom = model.DateFrom, + DateTo = model.DateTo, }) - .Select(student => ( - StudentFIO: $"{student.Value.Name} {student.Value.Surname}", - EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить")) - .ToList()) + .Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени + .Join(_documentStorage.GetFullList(), + t1 => t1.Value.Id, + t2 => t2.UserId, + (t1, t2) => new { student = t1, document = t2 }) + .Select(res => ( + StudentFIO: $"{res.student.Value.Name} {res.student.Value.Surname}", + Document: $"{res.document.Date}", + EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = res.student.Value.EducationStatusId })?.Name ?? "не удалось получить")) + .ToList() }) .ToList(); return result; } + public List StreamEducationStatus(List streams) + { + var result = streams + .Select(stream => new ReportStreamEducationStatusViewModel + { + StreamName = stream.Name, + StudentEdStatus = stream.StudentStream + .Select(student => ( + StudentFIO: $"{student.Value.Name} {student.Value.Surname}", + EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить")) + .ToList() + }) + .ToList(); + return result; + } + public void SaveBlanksToWordFile(ReportBindingModel model) { diff --git a/UniversityContracts/BindingModels/ReportBindingModel.cs b/UniversityContracts/BindingModels/ReportBindingModel.cs index f626497..8c8589b 100644 --- a/UniversityContracts/BindingModels/ReportBindingModel.cs +++ b/UniversityContracts/BindingModels/ReportBindingModel.cs @@ -9,6 +9,7 @@ namespace UniversityContracts.BindingModels public class ReportBindingModel { public string FileName { get; set; } = string.Empty; + public string DisciplineName { get; set; } = string.Empty; public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } public int? UserId { get; set; } diff --git a/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs b/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs index 98db3f7..f331890 100644 --- a/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs +++ b/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs @@ -10,8 +10,8 @@ namespace UniversityContracts.BusinessLogicContracts { public interface IReportCustomerLogic { - List GetStudentsDiscipline(List students); - List StreamStudentEdStatPeriod(ReportBindingModel model); + List GetDiscipline(ReportBindingModel model); + List StreamEducationStatus(List streams); void SaveBlanksToWordFile(ReportBindingModel model); diff --git a/UniversityContracts/ViewModels/DisciplineViewModel.cs b/UniversityContracts/ViewModels/DisciplineViewModel.cs index 75a67f1..a6cf5ff 100644 --- a/UniversityContracts/ViewModels/DisciplineViewModel.cs +++ b/UniversityContracts/ViewModels/DisciplineViewModel.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using UniversityModels.Models; namespace UniversityContracts.ViewModels { @@ -17,6 +18,6 @@ namespace UniversityContracts.ViewModels [DisplayName("Количество часов")] public int Hours { get; set; } = 0; [DisplayName("Тип оценки")] - public bool MarkType { get; set; } //TODO уточнить + public bool MarkType { get; set; } } }