getfilteredlist дела

This commit is contained in:
a.puchkina 2024-05-01 18:27:40 +04:00
parent bf7b75cc1e
commit 898abeba91
2 changed files with 22 additions and 11 deletions

View File

@ -20,14 +20,14 @@ namespace LawFirmDatabaseImplement.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 LawFirmDatabase();
return context.Cases
.Include(x => x.Clients).ThenInclude(x => x.Client)
@ -35,13 +35,23 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
else if (model.ExecutorId.HasValue)
{
using var context = new LawFirmDatabase();
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 LawFirmDatabase();
return context.Cases.Include(x => x.CaseClients)
.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

View File

@ -1,4 +1,5 @@
using LawFirmContracts.BindingModels;
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
@ -130,12 +131,12 @@ namespace LawFirmRestApi.Controllers
}
[HttpPost]
public void AddClientToCase(Tuple<CaseSearchModel, ClientViewModel> model)
{
try
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)
{