getfilteredlist консультации

This commit is contained in:
a.puchkina 2024-05-01 18:54:24 +04:00
parent 898abeba91
commit 47a1f54b4a

View File

@ -21,12 +21,12 @@ namespace LawFirmDatabaseImplement.Implements
}
public List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model)
{
if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
&& !model.ConsultationDate.HasValue)
if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
&& !model.ConsultationDate.HasValue && !model.CaseId.HasValue)
{
return new();
}
if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
if (model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
using var context = new LawFirmDatabase();
return context.Consultations
@ -38,14 +38,13 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
if (!model.GuarantorId.HasValue)
else if (model.GuarantorId.HasValue)
{
using var context = new LawFirmDatabase();
return context.Consultations
.Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer)
.Where(x => x.GuarantorId == model.GuarantorId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}