From aca649edf06073901ce0fa9c9571fc52a5c48bf8 Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Sun, 9 Apr 2023 01:01:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B3=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportCustomerLogic.cs | 21 +++----- .../BusinessLogics/ReportProviderLogic.cs | 50 ++++++++++++------- .../AbstractSaveToExcelProvider.cs | 12 +++++ .../AbstractSaveToPdfProvider.cs | 12 +++++ .../AbstractSaveToWordProvider.cs | 12 +++++ .../IReportCustomerLogic.cs | 2 +- .../IReportProviderLogic.cs | 2 +- 7 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToExcelProvider.cs create mode 100644 CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToPdfProvider.cs create mode 100644 CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToWordProvider.cs diff --git a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs index fcdbc31..911b91b 100644 --- a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs +++ b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportCustomerLogic.cs @@ -30,6 +30,7 @@ namespace CaseAccountingBusinessLogic.BusinessLogics { var result = _hearingStorage .GetFilteredList(new HearingSearchModel { UserId = model.UserId }) + .Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date) .Select(hearing => new ReportHearingSpecializationViewModel { Information = hearing.Information, @@ -44,9 +45,13 @@ namespace CaseAccountingBusinessLogic.BusinessLogics return result; } - public List GetLawyerHearing(ReportBindingModel model) + public List GetLawyerHearing(List models) { - var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { UserId = model.UserId }); + var lawyers = new List(); + foreach (var model in models) + { + lawyers.Add(_lawyerStorage.GetElement(new LawyerSearchModel { Id = model.Id})); + } var list = new List(); foreach(var lawyer in lawyers) @@ -68,18 +73,6 @@ namespace CaseAccountingBusinessLogic.BusinessLogics 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) diff --git a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs index 327c5d9..74cdacf 100644 --- a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs +++ b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/ReportProviderLogic.cs @@ -1,5 +1,6 @@ using CaseAccountingContracts.BindingModels; using CaseAccountingContracts.BusinessLogicContracts; +using CaseAccountingContracts.SearchModels; using CaseAccountingContracts.StoragesContracts; using CaseAccountingContracts.ViewModels; using System; @@ -25,46 +26,59 @@ namespace CaseAccountingBusinessLogic.BusinessLogics _lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage)); } - public List GetCaseSpecialization() + public List GetCaseSpecialization(List models) { - var сases = _caseStorage.GetFullList(); - var list = new List(); - foreach (var c in сases) - { - var report = new ReportCaseSpecializationViewModel - { - CaseName = c.Name, - Applicant = c.Applicant, - Defendant = c.Defendant, - Date = c.Date, - Specialization = c.Specialization, - }; - list.Add(report); - } - return list; + var сases = new List(); + 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 GetHearingLawyer(ReportBindingModel model) { - var hearings = _hearingStorage.GetFullList(); - var lawyers = _lawyerStorage.GetFullList(); + var hearings = _hearingStorage + .GetFilteredList(new HearingSearchModel { UserId = model.UserId}) + .Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date); var list = new List(); + 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 } } } diff --git a/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToExcelProvider.cs b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToExcelProvider.cs new file mode 100644 index 0000000..681ddf1 --- /dev/null +++ b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToExcelProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CaseAccountingBusinessLogic.OfficePackage +{ + public class AbstractSaveToExcelProvider + { + } +} diff --git a/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToPdfProvider.cs b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToPdfProvider.cs new file mode 100644 index 0000000..d8bc181 --- /dev/null +++ b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToPdfProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CaseAccountingBusinessLogic.OfficePackage +{ + public class AbstractSaveToPdfProvider + { + } +} diff --git a/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToWordProvider.cs b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToWordProvider.cs new file mode 100644 index 0000000..ff4597c --- /dev/null +++ b/CaseAccounting/CaseAccountingBusinessLogics/OfficePackage/AbstractSaveToWordProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CaseAccountingBusinessLogic.OfficePackage +{ + public class AbstractSaveToWordProvider + { + } +} diff --git a/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs b/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportCustomerLogic.cs index 62e7d6f..387673b 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(ReportBindingModel model); + List GetLawyerHearing(List models); List GetHearingSpecialization(ReportBindingModel model); diff --git a/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportProviderLogic.cs b/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportProviderLogic.cs index 48af92b..678ce92 100644 --- a/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportProviderLogic.cs +++ b/CaseAccounting/CaseAccountingContracts/BusinessLogicContracts/IReportProviderLogic.cs @@ -10,7 +10,7 @@ namespace CaseAccountingContracts.BusinessLogicContracts { public interface IReportProviderLogic { - List GetCaseSpecialization(); + List GetCaseSpecialization(List models); List GetHearingLawyer(ReportBindingModel model);