ReportCustomerLogic,
ReportBindingModel( +UserId)
This commit is contained in:
parent
9110f8be11
commit
7c2a4062fd
@ -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<ReportHearingSpecializationViewModel> 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<ReportLawyerHearingViewModel> GetLawyerHearing(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { UserId = model.UserId });
|
||||||
|
var list = new List<ReportLawyerHearingViewModel>();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,5 +14,7 @@ namespace CaseAccountingContracts.BindingModels
|
|||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
|
||||||
|
public int? UserId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
public interface IReportCustomerLogic
|
public interface IReportCustomerLogic
|
||||||
{
|
{
|
||||||
List<ReportLawyerHearingViewModel> GetLawyerHearing();
|
List<ReportLawyerHearingViewModel> GetLawyerHearing(ReportBindingModel model);
|
||||||
|
|
||||||
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ namespace CaseAccountingContracts.ViewModels
|
|||||||
|
|
||||||
public string Patronymic { get; set; } = string.Empty;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user