diff --git a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/ClientStorage.cs index 1463245..38e041a 100644 --- a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/ClientStorage.cs @@ -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(); } diff --git a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs index 5a143bd..3b5d489 100644 --- a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs @@ -27,12 +27,12 @@ namespace FurnitureAssemFileImplement.Implements public List 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(); } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs index e38ade9..c507ec0 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs @@ -5,5 +5,6 @@ public int? Id { get; set; } public string? Email { get; set; } + public string? Password { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs index dabf224..a816e97 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs @@ -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; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs index 2907901..4b8cc2a 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/ClientStorage.cs @@ -42,13 +42,13 @@ namespace FurnitureAssemblyDatabaseImplement.Implements public List 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(); } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs index 61c5fab..1ecd031 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs @@ -29,7 +29,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements public List 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(); } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs index f72ae5f..a4b75c1 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ClientStorage.cs @@ -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); } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs index 0396870..91d2476 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs @@ -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)); }