Case_accounting/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs

85 lines
3.4 KiB
C#
Raw Normal View History

using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
2023-04-09 01:01:14 +04:00
using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.StoragesContracts;
using CaseAccountingContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.BusinessLogics
{
public class ReportProviderLogic : IReportProviderLogic
{
private readonly ICaseStorage _caseStorage;
private readonly ISpecializationStorage _specializationStorage;
private readonly IHearingStorage _hearingStorage;
private readonly ILawyerStorage _lawyerStorage;
public ReportProviderLogic(ICaseStorage caseStorage, ISpecializationStorage specializationStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage)
{
_caseStorage = caseStorage ?? throw new ArgumentNullException(nameof(caseStorage));
_specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage));
_hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage));
_lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage));
}
2023-04-09 01:01:14 +04:00
public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
{
2023-04-09 01:01:14 +04:00
var сases = new List<CaseViewModel>();
foreach (var model in models)
сases.Add(_caseStorage.GetElement(new CaseSearchModel { Id = model.Id }));
return сases.Select(x => new ReportCaseSpecializationViewModel {
CaseName = x.Name,
Applicant = x.Applicant,
Defendant = x.Defendant,
Date = x.Date,
Specialization = x.Specialization,
}).ToList();
}
public List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model)
{
2023-04-09 01:01:14 +04:00
var hearings = _hearingStorage
.GetFilteredList(new HearingSearchModel { UserId = model.UserId})
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
var list = new List<ReportHearingLawyerViewModel>();
2023-04-09 01:01:14 +04:00
foreach (var hearing in hearings)
{
var record = new ReportHearingLawyerViewModel
{
Information = hearing.Information,
Date = hearing.Date,
Lawyers = new List<(string Surname, string Name, string Patronymic)>()
};
foreach (var lawyer in _caseStorage.GetElement(new CaseSearchModel { Id = hearing.CaseId }).Lawyers.Values)
{
record.Lawyers.Add((lawyer.Surname, lawyer.Name, lawyer.Patronymic));
}
list.Add(record);
}
return list;
}
public void SaveCaseSpecializationToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-09 01:01:14 +04:00
//TODO
}
public void SaveCaseSpecializationToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-09 01:01:14 +04:00
//TODO
}
public void SaveHearingLawyerToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
2023-04-09 01:01:14 +04:00
//TODO
}
}
}