2023-05-20 01:21:33 +04:00
|
|
|
|
using CaseAccountingBusinessLogic.OfficePackage;
|
|
|
|
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
2023-04-09 00:09:58 +04:00
|
|
|
|
using CaseAccountingContracts.BusinessLogicContracts;
|
|
|
|
|
using CaseAccountingContracts.SearchModels;
|
|
|
|
|
using CaseAccountingContracts.StoragesContracts;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
2023-05-23 01:50:02 +04:00
|
|
|
|
using CaseAccountingDataBaseImplement.Models;
|
2023-04-09 00:09:58 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
public class ReportCustomerLogic : IReportCustomerLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly ICaseStorage _caseStorage;
|
|
|
|
|
private readonly IHearingStorage _hearingStorage;
|
|
|
|
|
private readonly ILawyerStorage _lawyerStorage;
|
|
|
|
|
private readonly ISpecializationStorage _specializationStorage;
|
2023-05-20 01:21:33 +04:00
|
|
|
|
private readonly WordBuilderCustomer _wordBuilder;
|
|
|
|
|
private readonly ExcelBuilderCustomer _excelBuilder;
|
2023-04-09 00:09:58 +04:00
|
|
|
|
|
2023-05-20 01:21:33 +04:00
|
|
|
|
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
|
|
|
|
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
|
2023-04-09 00:09:58 +04:00
|
|
|
|
{
|
|
|
|
|
_caseStorage = caseStorage;
|
|
|
|
|
_hearingStorage = hearingStorage;
|
|
|
|
|
_lawyerStorage = lawyerStorage;
|
|
|
|
|
_specializationStorage = specializationStorage;
|
2023-05-20 01:21:33 +04:00
|
|
|
|
_wordBuilder = wordBuilder;
|
|
|
|
|
_excelBuilder = excelBuilder;
|
2023-04-09 00:09:58 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
var result = _hearingStorage
|
|
|
|
|
.GetFilteredList(new HearingSearchModel { UserId = model.UserId })
|
2023-04-09 01:01:14 +04:00
|
|
|
|
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date)
|
2023-04-09 00:09:58 +04:00
|
|
|
|
.Select(hearing => new ReportHearingSpecializationViewModel
|
|
|
|
|
{
|
|
|
|
|
Information = hearing.Information,
|
|
|
|
|
Date = hearing.Date,
|
|
|
|
|
Specialization = _caseStorage.GetElement(new CaseSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = hearing.CaseId
|
|
|
|
|
})?
|
|
|
|
|
.Specialization ?? "Не удалось найти специализацию."
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 01:21:33 +04:00
|
|
|
|
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
|
|
|
|
{
|
2023-05-23 01:50:02 +04:00
|
|
|
|
List <ReportLawyerHearingViewModel> list = new();
|
2023-05-20 01:21:33 +04:00
|
|
|
|
foreach (var lawyer in lawyers)
|
2023-04-09 00:09:58 +04:00
|
|
|
|
{
|
2023-05-23 01:50:02 +04:00
|
|
|
|
ReportLawyerHearingViewModel report = new ReportLawyerHearingViewModel
|
2023-04-09 00:09:58 +04:00
|
|
|
|
{
|
2023-05-23 01:50:02 +04:00
|
|
|
|
Lawyer = lawyer.Surname + " " + lawyer.Name + " " + lawyer.Patronymic,
|
|
|
|
|
Hearings = new()
|
2023-04-09 00:09:58 +04:00
|
|
|
|
};
|
2023-05-23 01:50:02 +04:00
|
|
|
|
var cases = _caseStorage.GetCaseMTM(lawyer.Id);
|
|
|
|
|
foreach (var caseModel in cases)
|
|
|
|
|
{
|
|
|
|
|
foreach (var hearing in _hearingStorage.GetFilteredList(new HearingSearchModel { CaseId = caseModel.Id }))
|
|
|
|
|
{
|
|
|
|
|
report.Hearings.Add("Номер слушания: " + hearing.Id.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(report);
|
2023-04-09 00:09:58 +04:00
|
|
|
|
}
|
2023-05-23 01:50:02 +04:00
|
|
|
|
return list;
|
2023-04-09 00:09:58 +04:00
|
|
|
|
}
|
2023-05-20 01:21:33 +04:00
|
|
|
|
|
|
|
|
|
public byte[] SaveListFile(LawyerHearingListBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
byte[] file = Array.Empty<byte>();
|
|
|
|
|
|
|
|
|
|
string title = "Список слушаний по выбранным юристам";
|
|
|
|
|
|
|
|
|
|
if (model.FileType == "docx")
|
|
|
|
|
{
|
|
|
|
|
_wordBuilder.CreateDocument();
|
|
|
|
|
_wordBuilder.CreateTitle(title);
|
|
|
|
|
_wordBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
|
|
|
|
|
file = _wordBuilder.GetFile();
|
|
|
|
|
}
|
|
|
|
|
else if (model.FileType == "xlsx")
|
|
|
|
|
{
|
|
|
|
|
_excelBuilder.CreateDocument();
|
|
|
|
|
_excelBuilder.CreateTitle(title);
|
|
|
|
|
_excelBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
|
|
|
|
|
file = _excelBuilder.GetFile();
|
|
|
|
|
}
|
|
|
|
|
return file;
|
|
|
|
|
}
|
2023-04-09 00:09:58 +04:00
|
|
|
|
}
|
|
|
|
|
}
|