OrderStorage GetFilteredList fix
This commit is contained in:
parent
e61adfda15
commit
74c055bc42
@ -22,9 +22,6 @@ namespace AutoWorkshopDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
//if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
// return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
if (Model.DateFrom.HasValue)
|
||||
@ -32,7 +29,7 @@ namespace AutoWorkshopDatabaseImplement.Implements
|
||||
return Context.Orders
|
||||
.Include(x => x.Repair)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo && (!Model.ClientId.HasValue || x.ClientId == Model.ClientId))
|
||||
.Where(x => (x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo) && (!Model.ClientId.HasValue || x.ClientId == Model.ClientId))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
using System;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Implements
|
||||
{
|
||||
@ -22,13 +23,17 @@ namespace AutoWorkshopFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
return new();
|
||||
if (Model.DateFrom.HasValue)
|
||||
{
|
||||
return _source.Orders
|
||||
.Where(x => (x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo) && (!Model.ClientId.HasValue || x.ClientId == Model.ClientId))
|
||||
.Select(x => AddClientFIO(AddRepairName(x.GetViewModel)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return _source.Orders
|
||||
.Where(x => x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo &&
|
||||
(!Model.ClientId.HasValue || x.ClientId == Model.ClientId))
|
||||
.Select(x => AddRepairName(x.GetViewModel))
|
||||
.Where(x => (Model.Id.HasValue && x.Id == Model.Id) || (Model.ClientId.HasValue && x.ClientId == Model.ClientId))
|
||||
.Select(x => AddClientFIO(AddRepairName(x.GetViewModel)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -29,22 +29,18 @@ namespace AutoWorkshopListImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
var Result = new List<OrderViewModel>();
|
||||
|
||||
if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
return Result;
|
||||
|
||||
foreach (var Order in _source.Orders)
|
||||
if (Model.DateFrom.HasValue)
|
||||
{
|
||||
if ((Order.DateCreate >= Model.DateFrom && Order.DateCreate <= Model.DateTo) &&
|
||||
(!Model.ClientId.HasValue || Model.ClientId == Model.ClientId))
|
||||
{
|
||||
Result.Add(JoinRepairName(Order.GetViewModel));
|
||||
break;
|
||||
}
|
||||
return _source.Orders
|
||||
.Where(x => (x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo) && (!Model.ClientId.HasValue || x.ClientId == Model.ClientId))
|
||||
.Select(x => JoinClientFIO(JoinRepairName(x.GetViewModel)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return Result;
|
||||
return _source.Orders
|
||||
.Where(x => (Model.Id.HasValue && x.Id == Model.Id) || (Model.ClientId.HasValue && x.ClientId == Model.ClientId))
|
||||
.Select(x => JoinClientFIO(JoinRepairName(x.GetViewModel)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel Model)
|
||||
|
Loading…
Reference in New Issue
Block a user