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