From a4843554ec8e14232811b4514faa2854b8daea39 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Sat, 6 Apr 2024 22:08:37 +0400 Subject: [PATCH] ) --- FlowerShopContracts/SearchModels/ClientSearchModel.cs | 1 + FlowerShopDatabaseImplement/ClientStorage.cs | 9 ++++++--- FlowerShopFileImplement/ClientStorage.cs | 8 +++++--- FlowerShopListImplement/ClientStorage.cs | 5 +++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/FlowerShopContracts/SearchModels/ClientSearchModel.cs b/FlowerShopContracts/SearchModels/ClientSearchModel.cs index 78fca61..4859ce8 100644 --- a/FlowerShopContracts/SearchModels/ClientSearchModel.cs +++ b/FlowerShopContracts/SearchModels/ClientSearchModel.cs @@ -11,5 +11,6 @@ namespace FlowerShopContracts.SearchModels public int? Id { get; set; } public string? ClientFIO { get; set; } public string? Email { get; set; } + public string? Password { get; set; } } } diff --git a/FlowerShopDatabaseImplement/ClientStorage.cs b/FlowerShopDatabaseImplement/ClientStorage.cs index 8ab0205..30c5bc1 100644 --- a/FlowerShopDatabaseImplement/ClientStorage.cs +++ b/FlowerShopDatabaseImplement/ClientStorage.cs @@ -22,14 +22,16 @@ namespace FlowerShopDatabaseImplement.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) && + string.IsNullOrEmpty(model.ClientFIO)) { return new(); } using var context = new FlowerShopDataBase(); 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 +45,8 @@ namespace FlowerShopDatabaseImplement.Implements using var context = new FlowerShopDataBase(); 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/FlowerShopFileImplement/ClientStorage.cs b/FlowerShopFileImplement/ClientStorage.cs index 68f9b3d..1198f5c 100644 --- a/FlowerShopFileImplement/ClientStorage.cs +++ b/FlowerShopFileImplement/ClientStorage.cs @@ -34,8 +34,9 @@ namespace FlowerShopFileImplement.Implements 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)))) + .Where(x => ((string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO.Contains(model.ClientFIO)) && + (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 FlowerShopFileImplement.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/FlowerShopListImplement/ClientStorage.cs b/FlowerShopListImplement/ClientStorage.cs index 62251be..3c0b343 100644 --- a/FlowerShopListImplement/ClientStorage.cs +++ b/FlowerShopListImplement/ClientStorage.cs @@ -32,7 +32,7 @@ namespace FlowerShopListImplement.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; } @@ -50,7 +50,8 @@ namespace FlowerShopListImplement.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; }