Compare commits

...

2 Commits

Author SHA1 Message Date
bekodeg
57e9a8a6b8 Merge branch 'labWork4' into labWork5 2024-05-19 17:01:08 +04:00
bekodeg
450d6d56c2 изменил file и list implement заказов 2024-05-19 16:52:54 +04:00
2 changed files with 15 additions and 11 deletions

View File

@ -15,7 +15,9 @@ namespace SushiBarFileImplement.Implements
}
public List<OrderViewModel> GetFullList()
{
return source.Orders.Select(x => AttachSushiName(x.GetViewModel)).ToList();
return source.Orders
.Select(x => AttachSushiName(x.GetViewModel))
.ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
@ -23,9 +25,13 @@ namespace SushiBarFileImplement.Implements
{
return new();
}
return source.Orders.Where(x =>
x.Id == model.Id).Select(x =>
AttachSushiName(x.GetViewModel)).ToList();
return source.Orders
.Where(o =>
(model.Id.HasValue && o.Id == model.Id) ||
(model.DateFrom.HasValue && model.DateTo.HasValue &&
model.DateFrom < o.DateCreate && o.DateCreate < model.DateTo))
.Select(x => AttachSushiName(x.GetViewModel))
.ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
@ -33,8 +39,8 @@ namespace SushiBarFileImplement.Implements
{
return null;
}
return AttachSushiName(source.Orders.FirstOrDefault(x =>
(x.Id == model.Id))?.GetViewModel);
return AttachSushiName(source.Orders
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel);
}
public OrderViewModel? Insert(OrderBindingModel model)
{

View File

@ -25,13 +25,11 @@ namespace SushiBarListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (model == null || !model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
if (order.Id == model.Id ||
(model.DateFrom.HasValue && model.DateTo.HasValue &&
model.DateFrom < order.DateCreate && order.DateCreate < model.DateTo)))
{
result.Add(AttachSushiName(order.GetViewModel));
}