ClientStorage GetFilteredList fix

This commit is contained in:
ShabOl 2024-04-13 00:32:02 +04:00
parent e4a611748c
commit bfe546dd2b
3 changed files with 16 additions and 21 deletions

View File

@ -19,15 +19,15 @@ namespace AutoWorkshopDatabaseImplement.Implements
public List<ClientViewModel> 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();
}

View File

@ -23,13 +23,13 @@ namespace AutoWorkshopFileImplement.Implements
public List<ClientViewModel> 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();
}

View File

@ -29,20 +29,15 @@ namespace AutoWorkshopListImplement.Implements
public List<ClientViewModel> GetFilteredList(ClientSearchModel Model)
{
var Result = new List<ClientViewModel>();
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)