конфликты мои конфликты

This commit is contained in:
frog24 2024-05-18 17:56:58 +04:00
parent b211423960
commit b365a146d3

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace ComputersShopDatabaseImplements.Implements
{
public class OrderStorage: IOrderStorage
public class OrderStorage : IOrderStorage
{
public OrderViewModel? GetElement(OrderSearchModel model)
{
@ -22,19 +22,19 @@ namespace ComputersShopDatabaseImplements.Implements
}
using var context = new ComputersShopDatabase();
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;
.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)
{
if (!model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Id.HasValue && !model.Status.HasValue)
{
if (!model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Id.HasValue && !model.Status.HasValue)
{
return new();
}
using var context = new ComputersShopDatabase();
@ -42,15 +42,15 @@ namespace ComputersShopDatabaseImplements.Implements
{
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
}
if (model.ClientId.HasValue)
{
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
}
if (model.Status.HasValue)
if (model.ClientId.HasValue)
{
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
}
if (model.Status.HasValue)
{
return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.Status.Equals(model.Status)).Select(x => x.GetViewModel).ToList();
}
return context.Orders.Where(x => x.Id == model.Id).Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
}
return context.Orders.Where(x => x.Id == model.Id).Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList()
{
@ -94,4 +94,4 @@ namespace ComputersShopDatabaseImplements.Implements
return null;
}
}
}
}