PIbd-21_Pyatakov_KM_Markov_.../UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs

111 lines
5.0 KiB
C#
Raw Normal View History

/*using System;
2023-04-09 00:48:03 +04:00
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicContracts;
using UniversityContracts.ViewModels;
using UniversityContracts.SearchModels;
using UniversityContracts.StoragesContracts;
using UniversityBusinessLogic.OfficePackage;
2023-04-09 03:05:40 +04:00
using System.Reflection;
using System.Net;
using System.Reflection.Metadata;
2023-04-09 00:48:03 +04:00
namespace UniversityBusinessLogic.BusinessLogics
{
public class ReportCustomerLogic : IReportCustomerLogic
{
private readonly IDocumentStorage _documentStorage;
private readonly IStudentStorage _studentStorage;
private readonly IEducationStatusStorage _educationStatusStorage;
private readonly IEducationGroupStorage _educationGroupStorage;
private readonly IDisciplineStorage _disciplineStorage;
private readonly IStreamStorage _streamStorage;
private readonly AbstractSaveToExcelProvider _saveToExcel;
private readonly AbstractSaveToWordProvider _saveToWord;
private readonly AbstractSaveToPdfProvider _saveToPdf;
public ReportCustomerLogic(IDocumentStorage documentStorage,
IStudentStorage studentStorage,
IEducationStatusStorage educationStatusStorage,
IEducationGroupStorage educationGroupStorage,
IDisciplineStorage disciplineStorage,
IStreamStorage streamStorage,
AbstractSaveToExcelProvider saveToExcel,
AbstractSaveToWordProvider saveToWord,
AbstractSaveToPdfProvider saveToPdf)
{
_documentStorage = documentStorage;
_studentStorage = studentStorage;
_educationStatusStorage = educationStatusStorage;
_educationGroupStorage = educationGroupStorage;
_disciplineStorage = disciplineStorage;
_streamStorage = streamStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
2023-04-09 03:05:40 +04:00
public List<ReportDisciplineViewModel> GetDiscipline(ReportBindingModel model)
2023-04-09 00:48:03 +04:00
{
2023-04-09 03:05:40 +04:00
var result = _streamStorage.GetFilteredList(new StreamSearchModel { Id = _disciplineStorage.GetElement(new DisciplineSearchModel { Name = model.DisciplineName })?.StreamId })
.Select(stream => new ReportDisciplineViewModel
2023-04-09 00:48:03 +04:00
{
2023-04-09 03:05:40 +04:00
DisciplineName = model.DisciplineName,
StudentEdStatus = stream.StudentStream
2023-04-09 00:48:03 +04:00
.Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel
{
UserId = model.UserId,
2023-04-09 03:05:40 +04:00
DateFrom = model.DateFrom,
DateTo = model.DateTo,
2023-04-09 00:48:03 +04:00
})
.Any(document => document.DocumentStudents.Contains(student.Value)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
2023-04-09 03:05:40 +04:00
.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<ReportStreamEducationStatusViewModel> StreamEducationStatus(List<StreamViewModel> streams)
{
var result = streams
.Select(stream => new ReportStreamEducationStatusViewModel
{
StreamName = stream.Name,
StudentEdStatus = stream.StudentStream
2023-04-09 00:48:03 +04:00
.Select(student => (
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
2023-04-09 03:05:40 +04:00
.ToList()
2023-04-09 00:48:03 +04:00
})
.ToList();
return result;
}
2023-04-09 03:05:40 +04:00
2023-04-09 00:48:03 +04:00
public void SaveBlanksToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}
*/