diff --git a/University/UniversityBusinessLogics/BusinessLogics/ReportLogic.cs b/University/UniversityBusinessLogics/BusinessLogics/ReportLogic.cs
new file mode 100644
index 0000000..e0f6957
--- /dev/null
+++ b/University/UniversityBusinessLogics/BusinessLogics/ReportLogic.cs
@@ -0,0 +1,133 @@
+using UniversityBusinessLogics.MailWorker;
+using UniversityBusinessLogics.OfficePackage;
+using UniversityContracts.BindingModels;
+using UniversityContracts.BusinessLogicContracts;
+using UniversityContracts.StoragesContracts;
+
+namespace UniversityBusinessLogics.BusinessLogics;
+
+public class ReportLogic : IReportLogic
+{
+ private readonly AbstractSaveToWord _saveToWord;
+ private readonly IDisciplineStorage _disciplineStorage;
+ private readonly IClientStorage _clientStorage;
+ private readonly AbstractSaveToExcel _saveToExcel;
+ private readonly IAccountStorage _accountStorage;
+ private readonly AbstractMailWorker _mailWorker;
+ private readonly AbstractSaveToPdf _saveToPdf;
+
+ public ReportLogic(AbstractSaveToWord saveToWord, IDisciplineStorage disciplineStorage, AbstractSaveToExcel saveToExcel,
+ AbstractMailWorker mailWorker, IAccountStorage accountStorage, AbstractSaveToPdf saveToPdf, IClientStorage clientStorage)
+ {
+ _mailWorker = mailWorker;
+ _accountStorage = accountStorage;
+ _saveToExcel = saveToExcel;
+ _saveToWord = saveToWord;
+ _disciplineStorage = disciplineStorage;
+ _saveToPdf = saveToPdf;
+ _clientStorage = clientStorage;
+ }
+
+ public void SaveDisciplinesToWord(ReportBindingModel option)
+ {
+ _saveToWord.CreateDoc(new()
+ {
+ FileName = option.FileName,
+ Stream = option.Stream,
+ Title = "Список дисциплин вместе с клиентами",
+ ReportObjects = _disciplineStorage.GetFilteredList(new() { ClientsIds = option.Ids?.ToList() })
+ .Select(x => (object)x).ToList(),
+ });
+ }
+
+ public void SaveDisciplinesToExcel(ReportBindingModel option)
+ {
+ var ids = option.Ids?.ToList();
+ _saveToExcel.CreateReportDisciplines(new()
+ {
+ FileName = option.FileName,
+ Stream = option.Stream,
+ Ids = ids,
+ Title = "Список дисциплин вместе с клиентами",
+ ReportObjects = _disciplineStorage.GetFilteredList(new() { ClientsIds = ids })
+ .Select(x => (object)x).ToList(),
+ Headers = new() { "Дисциплина", "Дата создания", "Дата прохождения" }
+ });
+ }
+
+ public void SendAccountsToEmail(ReportDateRangeBindingModel option, string email)
+ {
+ var accounts = _accountStorage.GetFilteredList(new()
+ {
+ DateFrom = option.DateFrom,
+ DateTo = option.DateTo,
+ });
+ option.Stream = new MemoryStream();
+ _saveToPdf.CreateDocForAccounts(new()
+ {
+ DateFrom = option.DateFrom,
+ DateTo = option.DateTo,
+ Stream = option.Stream,
+ Title = "Данные по клиентом с накопительными счетами за период",
+ ReportObjects = accounts.Select(x => (object)x).ToList()
+ });
+
+ _mailWorker.MailSendAsync(new()
+ {
+ FilesStreams = new() { new(option.Stream, "report.pdf") },
+ Subject = $"Отчет по накопительным счетам за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
+ MailAddress = email,
+ });
+ }
+
+ public void SaveClientsToWord(ReportBindingModel option)
+ {
+ _saveToWord.CreateDoc(new()
+ {
+ FileName = option.FileName,
+ Stream = option.Stream,
+ Title = "Список клиентов вместе с их дисциплинами",
+ ReportObjects = _clientStorage.GetFilteredList(new() { DisciplinesIds = option.Ids?.ToList() })
+ .Select(x => (object)x).ToList(),
+ });
+ }
+
+ public void SaveClientsToExcel(ReportBindingModel option)
+ {
+ _saveToExcel.CreateReportClients(new()
+ {
+ FileName = option.FileName,
+ Stream = option.Stream,
+ Ids = option.Ids?.ToList(),
+ Title = "Список клиентов вместе с их дисциплинами",
+ ReportObjects = _clientStorage.GetFilteredList(new() { DisciplinesIds = option.Ids?.ToList() })
+ .Select(x => (object)x).ToList(),
+ Headers = new() { "Клиент", "Дата", "Дисциплина", "Курс" }
+ });
+ }
+
+ public void SendRequirementsToEmail(ReportDateRangeBindingModel option, string email)
+ {
+ var dicscipline = _disciplineStorage.GetFilteredList(new()
+ {
+ DateFrom = option.DateFrom,
+ DateTo = option.DateTo,
+ });
+ option.Stream = new MemoryStream();
+ _saveToPdf.CreateDocForDisciplines(new()
+ {
+ DateFrom = option.DateFrom,
+ DateTo = option.DateTo,
+ Stream = option.Stream,
+ Title = "Данные по дисциплинам с требованиями за период",
+ ReportObjects = dicscipline.Select(x => (object)x).ToList()
+ });
+
+ _mailWorker.MailSendAsync(new()
+ {
+ FilesStreams = new() { new(option.Stream, "report.pdf") },
+ Subject = $"Отчет по требованиям за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
+ MailAddress = email,
+ });
+ }
+}
\ No newline at end of file
diff --git a/University/UniversityContracts/BindingModels/ReportBindingModel.cs b/University/UniversityContracts/BindingModels/ReportBindingModel.cs
new file mode 100644
index 0000000..1635afb
--- /dev/null
+++ b/University/UniversityContracts/BindingModels/ReportBindingModel.cs
@@ -0,0 +1,15 @@
+namespace UniversityContracts.BindingModels;
+
+///
+/// Опции для сохранения отчета, при сохранении указать одно из двух
+///
+public class ReportBindingModel
+{
+ public string? FileName { get; set; }
+ public Stream? Stream { get; set; }
+
+ ///
+ /// Массив айдишников по которым происходит выборка
+ ///
+ public int[]? Ids { get; set; }
+}
\ No newline at end of file
diff --git a/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs b/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs
new file mode 100644
index 0000000..a0d7808
--- /dev/null
+++ b/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UniversityContracts.BindingModels
+{
+ public class ReportDateRangeBindingModel
+ {
+ public string? FileName { get; set; }
+ public Stream? Stream { get; set; }
+
+ public DateOnly DateFrom { get; set; }
+ public DateOnly DateTo { get; set; }
+ }
+}
diff --git a/University/UniversityContracts/BusinessLogicContracts/IReportLogic.cs b/University/UniversityContracts/BusinessLogicContracts/IReportLogic.cs
new file mode 100644
index 0000000..01ccc44
--- /dev/null
+++ b/University/UniversityContracts/BusinessLogicContracts/IReportLogic.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UniversityContracts.BindingModels;
+
+namespace UniversityContracts.BusinessLogicContracts
+{
+ public interface IReportLogic
+ {
+ void SaveDisciplinesToWord(ReportBindingModel option);
+
+ void SaveDisciplinesToExcel(ReportBindingModel option);
+
+ void SendAccountsToEmail(ReportDateRangeBindingModel option, string email);
+ void SaveClientsToWord(ReportBindingModel option);
+
+ void SaveClientsToExcel(ReportBindingModel option);
+
+ void SendRequirementsToEmail(ReportDateRangeBindingModel option, string email);
+ }
+}