Merge branch 'lab4_base' into lab4_hard
This commit is contained in:
commit
7c70546980
@ -27,12 +27,19 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => x.Id.Equals(model.Id))
|
||||
.Select(x => GetOrderViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
return source.Orders
|
||||
.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Where(x => model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => GetOrderViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
|
@ -29,16 +29,25 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Furniture)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return context.Orders
|
||||
.Include(x => x.Furniture)
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
.Include(x => x.Furniture)
|
||||
.Where(x => model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
|
@ -51,11 +51,26 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
|
||||
{
|
||||
if (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||
return new();
|
||||
}
|
||||
var result = new List<OrderViewModel>();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id.Equals(model.Id))
|
||||
{
|
||||
result.Add(GetOrderViewModel(order));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||
{
|
||||
result.Add(GetOrderViewModel(order));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user