From e90206d910e757bc30422fe76809563906cbe79e Mon Sep 17 00:00:00 2001 From: Artyom_Yashin Date: Sat, 6 Apr 2024 18:56:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=81=D0=B2=D0=BE=D1=80=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchModels/ClientSearchModel.cs | 1 + .../Implements/ClientStorage.cs | 8 +++++--- .../Implements/ClientStorage.cs | 8 +++++--- .../Implements/ClientStorage.cs | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ComputersShop/ComputersShopContracts/SearchModels/ClientSearchModel.cs b/ComputersShop/ComputersShopContracts/SearchModels/ClientSearchModel.cs index e9cbec3..b144dc0 100644 --- a/ComputersShop/ComputersShopContracts/SearchModels/ClientSearchModel.cs +++ b/ComputersShop/ComputersShopContracts/SearchModels/ClientSearchModel.cs @@ -11,5 +11,6 @@ namespace ComputersShopContracts.SearchModels public int? Id { get; set; } public string? ClientFIO { get; set; } public string? Email { get; set; } + public string? Password { get; set; } } } diff --git a/ComputersShop/ComputersShopDatabaseImplement/Implements/ClientStorage.cs b/ComputersShop/ComputersShopDatabaseImplement/Implements/ClientStorage.cs index 55113a4..4186ba1 100644 --- a/ComputersShop/ComputersShopDatabaseImplement/Implements/ClientStorage.cs +++ b/ComputersShop/ComputersShopDatabaseImplement/Implements/ClientStorage.cs @@ -22,14 +22,15 @@ namespace ComputersShopDatabaseImplement.Implements } public List GetFilteredList(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email)) + if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password)) { return new(); } using var context = new ComputersShopDatabase(); return context.Clients .Where(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO.Contains(model.ClientFIO) && - (string.IsNullOrEmpty(model.Email) || x.ClientFIO.Contains(model.Email)))) + (string.IsNullOrEmpty(model.Email) || x.ClientFIO.Contains(model.Email)) && + (string.IsNullOrEmpty(model.Password) || x.ClientFIO.Contains(model.Password)))) .Select(x => x.GetViewModel) .ToList(); } @@ -43,7 +44,8 @@ namespace ComputersShopDatabaseImplement.Implements using var context = new ComputersShopDatabase(); return context.Clients .FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) && - (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email)) + (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) && + (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) ?.GetViewModel; } public ClientViewModel? Insert(ClientBindingModel model) diff --git a/ComputersShop/ComputersShopFileImplement/Implements/ClientStorage.cs b/ComputersShop/ComputersShopFileImplement/Implements/ClientStorage.cs index 7f01685..48625ff 100644 --- a/ComputersShop/ComputersShopFileImplement/Implements/ClientStorage.cs +++ b/ComputersShop/ComputersShopFileImplement/Implements/ClientStorage.cs @@ -27,13 +27,14 @@ namespace ComputersShopFileImplement.Implements public List GetFilteredList(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email)) + if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password)) { return new(); } return source.Clients .Where(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO.Contains(model.ClientFIO) && - (string.IsNullOrEmpty(model.Email) || x.ClientFIO.Contains(model.Email)))) + (string.IsNullOrEmpty(model.Email) || x.ClientFIO.Contains(model.Email)) && + (string.IsNullOrEmpty(model.Password) || x.ClientFIO.Contains(model.Password)))) .Select(x => x.GetViewModel) .ToList(); } @@ -41,7 +42,8 @@ namespace ComputersShopFileImplement.Implements { return source.Clients .FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) && - (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email)) + (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) && + (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) ?.GetViewModel; } public ClientViewModel? Insert(ClientBindingModel model) diff --git a/ComputersShop/ComputersShopListImplement/Implements/ClientStorage.cs b/ComputersShop/ComputersShopListImplement/Implements/ClientStorage.cs index 3a2e883..7364070 100644 --- a/ComputersShop/ComputersShopListImplement/Implements/ClientStorage.cs +++ b/ComputersShop/ComputersShopListImplement/Implements/ClientStorage.cs @@ -31,7 +31,7 @@ namespace ComputersShopListImplement.Implements model) { var result = new List(); - if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email)) + if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password)) { return result; } @@ -49,7 +49,8 @@ namespace ComputersShopListImplement.Implements foreach (var client in _source.Clients) { if ((string.IsNullOrEmpty(model.ClientFIO) || client.ClientFIO == model.ClientFIO) && - (!model.Id.HasValue || client.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || client.Email == model.Email)) + (!model.Id.HasValue || client.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || client.Email == model.Email) && + (string.IsNullOrEmpty(model.Password) || client.Password == model.Password)) { return client.GetViewModel; }