Добавлена возможность выбирать заказы по множеству статусов одновременно
This commit is contained in:
parent
5bea31e5bd
commit
520ea2f1d5
@ -28,6 +28,13 @@ namespace ConfectioneryFileImplement
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model.ImplementerId.HasValue && model.Statusses != null)
|
||||
{
|
||||
return _source.Orders
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId &&
|
||||
model.Statusses.Contains(x.Status))
|
||||
?.GetViewModel;
|
||||
}
|
||||
if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return _source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||
@ -55,10 +62,10 @@ namespace ConfectioneryFileImplement
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (!model.Id.HasValue && model.Status.HasValue)
|
||||
if (!model.Id.HasValue && model.Statusses != null)
|
||||
{
|
||||
return _source.Orders
|
||||
.Where(x => x.Status == model.Status)
|
||||
.Where(x => model.Statusses.Contains(x.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -30,7 +30,14 @@ namespace ConfectioneryListImplement
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model.ImplementerId.HasValue)
|
||||
if (model.ImplementerId.HasValue && model.Statusses != null)
|
||||
{
|
||||
return _source.Orders
|
||||
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId &&
|
||||
model.Statusses.Contains(x.Status))
|
||||
?.GetViewModel;
|
||||
}
|
||||
if (model.ImplementerId.HasValue)
|
||||
{
|
||||
return _source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||
}
|
||||
@ -65,10 +72,10 @@ namespace ConfectioneryListImplement
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (!model.Id.HasValue && model.Status.HasValue)
|
||||
if (!model.Id.HasValue && model.Statusses != null)
|
||||
{
|
||||
return _source.Orders
|
||||
.Where(x => x.Status == model.Status)
|
||||
.Where(x => model.Statusses.Contains(x.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace ConfectioneryContracts.SearchModels
|
||||
|
||||
public int? ImplementerId { get; set; }
|
||||
|
||||
public OrderStatus? Status { get; set; }
|
||||
public List<OrderStatus>? Statusses { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace ConfectioneryDatabaseImplement.Implements
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x =>
|
||||
(!model.Status.HasValue || model.Status.HasValue && x.Status == model.Status) &&
|
||||
(model.Statusses == null || model.Statusses != null && model.Statusses.Contains(x.Status)) &&
|
||||
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
|
||||
model.Id.HasValue && x.Id == model.Id
|
||||
)
|
||||
@ -57,9 +57,9 @@ namespace ConfectioneryDatabaseImplement.Implements
|
||||
.Where(x => model.DateFrom <= x.DateCreate.Date &&
|
||||
x.DateCreate.Date <= model.DateTo);
|
||||
}
|
||||
else if (model.Status.HasValue)
|
||||
else if (model.Statusses != null)
|
||||
{
|
||||
queryWhere = context.Orders.Where(x => x.Status == model.Status);
|
||||
queryWhere = context.Orders.Where(x => model.Statusses.Contains(x.Status));
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user