111 lines
4.9 KiB
C#
Raw Normal View History

using System;
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;
2023-04-08 20:16:42 +04:00
using UniversityBusinessLogic.OfficePackage;
namespace UniversityBusinessLogic.BusinessLogics
{
public class ReportProviderLogic : IReportProviderLogic
{
private readonly IDocumentStorage _documentStorage;
2023-04-08 20:16:42 +04:00
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 ReportProviderLogic(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-08 14:02:34 +04:00
public List<ReportStudentsDisciplineViewModel> GetStudentsDiscipline(ReportBindingModel model)
{
2023-04-08 20:16:42 +04:00
var result = _studentStorage
.GetFilteredList(new StudentSearchModel { UserId = model.UserId })
.Select(student => new ReportStudentsDisciplineViewModel
{
StudentFIO = $"{student.Name} {student.Surname}",
Disciplines = _streamStorage.GetFilteredList(new StreamSearchModel { UserId = model.UserId })
.Where(stream => stream.StudentStream.ContainsKey(student.Id))
.Join(_disciplineStorage.GetFilteredList(new DisciplineSearchModel { UserId = model.UserId }),
stream => stream.Id,
discipline => discipline.StreamId,
(stream, discipline) => discipline.Name)
.ToList()
})
.ToList();
return result;
}
2023-04-08 20:16:42 +04:00
public List<ReportStreamStudentEdStatPeriodViewModel> GetStreamStudentEdStatPeriod(ReportBindingModel model)
{
2023-04-08 20:16:42 +04:00
var result = _streamStorage
.GetFilteredList(new StreamSearchModel { UserId = model.UserId })
.Select(stream => new ReportStreamStudentEdStatPeriodViewModel
{
StreamName = stream.Name,
StudentEdStatus = stream.StudentStream
.Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel
{
UserId = model.UserId,
DateFrom = model.DateFrom,
DateTo = model.DateTo,
})
.Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
.Select(student => (
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
EdStatus: _educationStatusStorage.GetFilteredList(new EducationStatusSearchModel { UserId = model.UserId })
.First(x => x.Id == student.Value.EducationStatusId).Name))
.ToList()
})
.ToList();
return result;
}
public void SaveBlanksToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-08 20:16:42 +04:00
//TODO
}
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-08 20:16:42 +04:00
//TODO
}
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-08 20:16:42 +04:00
//TODO
}
}
}