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 ReportCustomerLogic : IReportCustomerLogic { private readonly ICaseStorage _caseStorage; private readonly IHearingStorage _hearingStorage; private readonly ILawyerStorage _lawyerStorage; private readonly ISpecializationStorage _specializationStorage; public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage) { _caseStorage = caseStorage; _hearingStorage = hearingStorage; _lawyerStorage = lawyerStorage; _specializationStorage = specializationStorage; } public List GetHearingSpecialization(ReportBindingModel model) { var result = _hearingStorage .GetFilteredList(new HearingSearchModel { UserId = model.UserId }) .Select(hearing => new ReportHearingSpecializationViewModel { Information = hearing.Information, Date = hearing.Date, Specialization = _caseStorage.GetElement(new CaseSearchModel { Id = hearing.CaseId })? .Specialization ?? "Не удалось найти специализацию." }) .ToList(); return result; } public List GetLawyerHearing(ReportBindingModel model) { var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { UserId = model.UserId }); var list = new List(); foreach(var lawyer in lawyers) { var record = new ReportLawyerHearingViewModel { Name = lawyer.Name, Surname = lawyer.Surname, Patronymic = lawyer.Patronymic, Hearings = new List<(DateTime Date, string Information)>() }; var cases = _caseStorage.GetFullList() .Where(x => x.Lawyers.ContainsKey(lawyer.Id)); foreach (var _case in cases) { record.Hearings.Add((_hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id}).Date, _hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id })?.Information ?? "Не удалось найти информацию.")); } list.Add(record); } return list; /* var result = _lawyerStorage .GetFilteredList(new LawyerSearchModel { UserId = model.UserId }) .Select(lawyer => new ReportLawyerHearingViewModel { Name = lawyer.Name, Surname = lawyer.Surname, Patronymic = lawyer.Patronymic, Hearings = new List<(DateTime Date, string Information)>() }) .ToList(); return result;*/ } public void SaveHearingSpecializationToPdfFile(ReportBindingModel model) { throw new NotImplementedException(); } public void SaveLawyerHearingToExcelFile(ReportBindingModel model) { throw new NotImplementedException(); } public void SaveLawyerHearingToWordFile(ReportBindingModel model) { throw new NotImplementedException(); } } }