From 7c2a4062fd6edf37e7e631da9e653769caf54168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Sun, 9 Apr 2023 00:09:58 +0400 Subject: [PATCH] ReportCustomerLogic, ReportBindingModel( +UserId) --- .../BusinessLogics/ReportCustomerLogic.cs | 100 ++++++++++++++++++ .../BindingModels/ReportBindingModel.cs | 2 + .../IReportCustomerLogic.cs | 2 +- .../ReportLawyerHearingViewModel.cs | 2 +- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs diff --git a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs new file mode 100644 index 0000000..fcdbc31 --- /dev/null +++ b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs @@ -0,0 +1,100 @@ +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(); + } + } +} diff --git a/CaseAccounting/CaseAccountingContracts/BindingModels/ReportBindingModel.cs b/CaseAccounting/CaseAccountingContracts/BindingModels/ReportBindingModel.cs index 5d2f3b7..c857950 100644 --- a/CaseAccounting/CaseAccountingContracts/BindingModels/ReportBindingModel.cs +++ b/CaseAccounting/CaseAccountingContracts/BindingModels/ReportBindingModel.cs @@ -14,5 +14,7 @@ namespace CaseAccountingContracts.BindingModels public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } + + public int? UserId { get; set; } } } diff --git a/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs b/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs index 0667e8e..62e7d6f 100644 --- a/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs +++ b/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs @@ -10,7 +10,7 @@ namespace CaseAccountingContracts.BusinessLogicContracts { public interface IReportCustomerLogic { - List GetLawyerHearing(); + List GetLawyerHearing(ReportBindingModel model); List GetHearingSpecialization(ReportBindingModel model); diff --git a/CaseAccounting/CaseAccountingContracts/ViewModels/ReportLawyerHearingViewModel.cs b/CaseAccounting/CaseAccountingContracts/ViewModels/ReportLawyerHearingViewModel.cs index 4ff7825..f1c8579 100644 --- a/CaseAccounting/CaseAccountingContracts/ViewModels/ReportLawyerHearingViewModel.cs +++ b/CaseAccounting/CaseAccountingContracts/ViewModels/ReportLawyerHearingViewModel.cs @@ -14,6 +14,6 @@ namespace CaseAccountingContracts.ViewModels public string Patronymic { get; set; } = string.Empty; - List<(DateTime Date, string Information)> Hearings { get; set; } = new(); + public List<(DateTime Date, string Information)> Hearings { get; set; } = new(); } }