diff --git a/AutoWorkshopDatabaseImplement/Implements/ClientStorage.cs b/AutoWorkshopDatabaseImplement/Implements/ClientStorage.cs index b75941f..4151748 100644 --- a/AutoWorkshopDatabaseImplement/Implements/ClientStorage.cs +++ b/AutoWorkshopDatabaseImplement/Implements/ClientStorage.cs @@ -19,15 +19,15 @@ namespace AutoWorkshopDatabaseImplement.Implements public List GetFilteredList(ClientSearchModel Model) { - if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email) && string.IsNullOrEmpty(Model.Password)) + if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email)) return new(); using var Context = new AutoWorkshopDatabase(); return Context.Clients - .Where(x => (string.IsNullOrEmpty(Model.ClientFIO) || x.ClientFIO.Contains(Model.ClientFIO) && - (string.IsNullOrEmpty(Model.Email) || x.Email.Contains(Model.Email)) && - (string.IsNullOrEmpty(Model.Password) || x.Password.Contains(Model.Password)))) + .Where(x => + (!string.IsNullOrEmpty(Model.ClientFIO) && x.ClientFIO.Contains(Model.ClientFIO)) || + (!string.IsNullOrEmpty(Model.Email) && x.Email.Contains(Model.Email))) .Select(x => x.GetViewModel) .ToList(); } diff --git a/AutoWorkshopFileImplement/Implements/ClientStorage.cs b/AutoWorkshopFileImplement/Implements/ClientStorage.cs index 6b9fa6c..8b1a80c 100644 --- a/AutoWorkshopFileImplement/Implements/ClientStorage.cs +++ b/AutoWorkshopFileImplement/Implements/ClientStorage.cs @@ -23,13 +23,13 @@ namespace AutoWorkshopFileImplement.Implements public List GetFilteredList(ClientSearchModel Model) { - if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email) && string.IsNullOrEmpty(Model.Password)) + if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email)) return new(); return _source.Clients - .Where(x => (string.IsNullOrEmpty(Model.ClientFIO) || x.ClientFIO.Contains(Model.ClientFIO) && - (string.IsNullOrEmpty(Model.Email) || x.Email.Contains(Model.Email)) && - (string.IsNullOrEmpty(Model.Password) || x.Password.Contains(Model.Password)))) + .Where(x => + (!string.IsNullOrEmpty(Model.ClientFIO) && x.ClientFIO.Contains(Model.ClientFIO)) || + (!string.IsNullOrEmpty(Model.Email) && x.Email.Contains(Model.Email))) .Select(x => x.GetViewModel) .ToList(); } diff --git a/AutoWorkshopImplement/Implements/ClientStorage.cs b/AutoWorkshopImplement/Implements/ClientStorage.cs index a361486..047742f 100644 --- a/AutoWorkshopImplement/Implements/ClientStorage.cs +++ b/AutoWorkshopImplement/Implements/ClientStorage.cs @@ -29,20 +29,15 @@ namespace AutoWorkshopListImplement.Implements public List GetFilteredList(ClientSearchModel Model) { - var Result = new List(); - - if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email) && string.IsNullOrEmpty(Model.Password)) - return Result; + if (string.IsNullOrEmpty(Model.ClientFIO) && string.IsNullOrEmpty(Model.Email)) + return new(); - foreach (var Client in _source.Clients) - { - if (Client.ClientFIO.Contains(Model.ClientFIO)) - { - Result.Add(Client.GetViewModel); - } - } - - return Result; + return _source.Clients + .Where(x => + (!string.IsNullOrEmpty(Model.ClientFIO) && x.ClientFIO.Contains(Model.ClientFIO)) || + (!string.IsNullOrEmpty(Model.Email) && x.Email.Contains(Model.Email))) + .Select(x => x.GetViewModel) + .ToList(); } public ClientViewModel? GetElement(ClientSearchModel Model)