getfilteredlist дела
This commit is contained in:
parent
bf7b75cc1e
commit
898abeba91
@ -20,13 +20,13 @@ namespace LawFirmDatabaseImplement.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 LawFirmDatabase();
|
using var context = new LawFirmDatabase();
|
||||||
return context.Cases
|
return context.Cases
|
||||||
@ -34,6 +34,16 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
.Where(x => x.ExecutorId == model.ExecutorId).ToList()
|
.Where(x => x.ExecutorId == model.ExecutorId).ToList()
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
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)
|
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
@ -41,7 +51,7 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
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
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using LawFirmContracts.BindingModels;
|
using LawFirmBusinessLogic.BusinessLogics;
|
||||||
|
using LawFirmContracts.BindingModels;
|
||||||
using LawFirmContracts.BusinessLogicContracts;
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
using LawFirmContracts.SearchModels;
|
using LawFirmContracts.SearchModels;
|
||||||
using LawFirmContracts.ViewModels;
|
using LawFirmContracts.ViewModels;
|
||||||
@ -130,12 +131,12 @@ namespace LawFirmRestApi.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…
Reference in New Issue
Block a user