внесение нужных изменений во все реализации OrserStorage лаб6
This commit is contained in:
parent
2f39bace9a
commit
6573a0bfbb
@ -24,11 +24,17 @@ namespace ComputersShopFileImplements.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFiltredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
|
||||
return source.Orders
|
||||
.Where(x => x.Id == model.Id ||
|
||||
model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
|
||||
x.ClientId == model.ClientId ||
|
||||
model.Status.Equals(x.Status))
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -36,6 +42,10 @@ namespace ComputersShopFileImplements.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (model.ImplementerId.HasValue && model.Status != null)
|
||||
{
|
||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
|
||||
}
|
||||
return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id));
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -77,6 +87,8 @@ namespace ComputersShopFileImplements.Implements
|
||||
var viewModel = order.GetViewModel;
|
||||
var computer = source.Computers.FirstOrDefault(x => x.Id == order.ComputerId);
|
||||
viewModel.ComputerName = computer?.ComputerName;
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||
viewModel.ClientFIO = client.ClientFIO;
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,15 @@ namespace ComputersShopDatabaseImplements.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputersShopDatabase();
|
||||
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Computer)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x =>
|
||||
(model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
|
||||
(model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
public List<OrderViewModel> GetFiltredList(OrderSearchModel model)
|
||||
{
|
||||
|
@ -34,11 +34,44 @@ namespace ComputersShopListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AddComputerName(order.GetViewModel));
|
||||
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||
{
|
||||
result.Add(AddComputerName(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.ClientId != null)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.ClientId == model.ClientId)
|
||||
{
|
||||
result.Add(AddComputerName(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.ImplementerId != null)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.ImplementerId == model.ImplementerId)
|
||||
{
|
||||
result.Add(AddComputerName(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Status.Equals(order.Status))
|
||||
{
|
||||
result.Add(AddComputerName(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -55,6 +88,14 @@ namespace ComputersShopListImplement.Implements
|
||||
{
|
||||
return AddComputerName(order.GetViewModel);
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
|
||||
{
|
||||
return order.GetViewModel;
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
|
||||
{
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user