Добавил вохможность поиска заказа по статусу и исполнителю

This commit is contained in:
Никита Потапов 2024-04-22 10:58:35 +04:00
parent 0ef5453070
commit 86fa2bf375
4 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,6 @@
namespace SecuritySystemContracts.SearchModels
using SecuritySystemDataModels.Enums;
namespace SecuritySystemContracts.SearchModels
{
public class OrderSearchModel
{
@ -7,5 +9,6 @@
public DateTime? DateTo { get; set; }
public int? ClientId { get; set; }
public int? ImplementerId { get; set; }
public OrderStatus? Status { get; set; }
}
}

View File

@ -25,12 +25,21 @@ namespace SecuritySystemDatabaseImplement.Implements
var orders = context.Orders
.Include(x => x.Secure)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Select(x => x.GetViewModel)
.ToList();
if (model.Id.HasValue)
{
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
}
if (model.Status.HasValue)
{
orders = orders.Where(x => x.Status == model.Status.Value).ToList();
}
if (model.ImplementerId.HasValue)
{
orders = orders.Where(x => x.ImplementerId == model.ImplementerId.Value).ToList();
}
if (model.DateFrom.HasValue)
{
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();

View File

@ -33,6 +33,14 @@ namespace SecuritySystemFileImplement.Implements
{
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
}
if (model.Status.HasValue)
{
orders = orders.Where(x => x.Status == model.Status.Value).ToList();
}
if (model.ImplementerId.HasValue)
{
orders = orders.Where(x => x.ImplementerId == model.ImplementerId.Value).ToList();
}
if (model.DateFrom.HasValue)
{
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();

View File

@ -31,6 +31,14 @@ namespace SecuritySystemListImplement.Implements
{
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
}
if (model.Status.HasValue)
{
orders = orders.Where(x => x.Status == model.Status.Value).ToList();
}
if (model.ImplementerId.HasValue)
{
orders = orders.Where(x => x.ImplementerId == model.ImplementerId.Value).ToList();
}
if (model.DateFrom.HasValue)
{
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();