Case_accounting/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs
2023-04-09 01:01:14 +04:00

85 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
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));
}
public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
{
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)
{
var hearings = _hearingStorage
.GetFilteredList(new HearingSearchModel { UserId = model.UserId})
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
var list = new List<ReportHearingLawyerViewModel>();
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();
//TODO
}
public void SaveCaseSpecializationToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
//TODO
}
public void SaveHearingLawyerToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
//TODO
}
}
}