дела и консультации - GetFilteredList
This commit is contained in:
parent
9a2fe62b41
commit
9fa75b7c3b
@ -20,13 +20,13 @@ namespace LawCompanyDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public List<CaseViewModel> GetFilteredList(CaseSearchModel model)
|
public List<CaseViewModel> GetFilteredList(CaseSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
|
||||||
&& !model.ExecutorId.HasValue)
|
&& !model.ExecutorId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ExecutorId.HasValue)
|
if (model.ExecutorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Cases
|
return context.Cases
|
||||||
@ -35,13 +35,23 @@ namespace LawCompanyDatabaseImplement.Implements
|
|||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
else if (model.ExecutorId.HasValue)
|
||||||
|
{
|
||||||
|
using var context = new LawCompanyDatabase();
|
||||||
|
return context.Cases
|
||||||
|
.Include(x => x.Clients)
|
||||||
|
.ThenInclude(x => x.Client)
|
||||||
|
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Cases.Include(x => x.CaseClients)
|
return context.Cases.Include(x => x.CaseClients)
|
||||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel).ToList()
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -22,11 +22,11 @@ namespace LawCompanyDatabaseImplement.Implements
|
|||||||
public List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model)
|
public List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
|
if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
|
||||||
&& !model.ConsultationDate.HasValue)
|
&& !model.ConsultationDate.HasValue && !model.CaseId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
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 LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Consultations
|
return context.Consultations
|
||||||
@ -38,14 +38,13 @@ namespace LawCompanyDatabaseImplement.Implements
|
|||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
if (!model.GuarantorId.HasValue)
|
else if (model.GuarantorId.HasValue)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Consultations
|
return context.Consultations
|
||||||
.Include(x => x.Lawyers)
|
.Include(x => x.Lawyers)
|
||||||
.ThenInclude(x => x.Lawyer)
|
.ThenInclude(x => x.Lawyer)
|
||||||
.Where(x => x.GuarantorId == model.GuarantorId)
|
.Where(x => x.GuarantorId == model.GuarantorId)
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -130,12 +130,12 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void AddClientToCase(Tuple<CaseSearchModel, ClientViewModel> model)
|
public void AddClientToCase(Tuple<CaseSearchModel, int> model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var modelClient = _clientlogic.ReadElement(new ClientSearchModel { Id = model.Item2 });
|
||||||
_logic.AddClientToCase(model.Item1, model.Item2);
|
if (modelClient != null) _logic.AddClientToCase(model.Item1, modelClient);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user