Правки в моделях поиска

This commit is contained in:
prodigygirl 2023-03-25 13:06:37 +04:00
parent 9391517849
commit 6290c54f2c
8 changed files with 11 additions and 9 deletions

View File

@ -51,7 +51,7 @@ namespace FurnitureAssemFileImplement.Implements
return new();
}
return source.Clients
.Where(x => x.Email.Contains(model.Email))
.Where(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -27,12 +27,12 @@ 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 && !model.ClientId.HasValue)
{
return new();
}
return source.Orders
.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId)
.Select(x => GetOrderViewModel(x))
.ToList();
}

View File

@ -5,5 +5,6 @@
public int? Id { get; set; }
public string? Email { get; set; }
public string? Password { get; set; }
}
}

View File

@ -11,5 +11,6 @@ namespace FurnitureAssemblyContracts.SearchModels
public int? Id { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? ClientId { get; set; }
}
}

View File

@ -42,13 +42,13 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Email))
if (string.IsNullOrEmpty(model.Email) || string.IsNullOrEmpty(model.Password))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Clients
.Where(x => x.Email.Contains(model.Email))
.Where(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -29,7 +29,7 @@ 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 && !model.ClientId.HasValue)
{
return new();
}
@ -37,7 +37,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Furniture)
.Include(x => x.Client)
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Implements
}
foreach (var client in _source.Clients)
{
if (client.Email.Contains(model.Email))
if (client.Email.Equals(model.Email) && client.Password.Equals(model.Password))
{
result.Add(client.GetViewModel);
}

View File

@ -55,7 +55,7 @@ namespace FurnitureAssemblyListImplement.Implements
foreach (var order in _source.Orders)
{
if (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
if (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo || order.ClientId.Equals(model.ClientId))
{
result.Add(GetOrderViewModel(order));
}