filter by email

This commit is contained in:
VictoriaPresnyakova 2023-04-30 19:59:13 +04:00
parent 0961c271c8
commit 562ad85327
3 changed files with 6 additions and 6 deletions

View File

@ -40,12 +40,12 @@ namespace JewelryStoreDatabaseImplement.Implements
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{ {
if (string.IsNullOrEmpty(model.ClientFIO)) if (string.IsNullOrEmpty(model.Email))
{ {
return new(); return new();
} }
using var context = new JewelryStoreDataBase(); using var context = new JewelryStoreDataBase();
return context.Clients.Where(x => x.ClientFIO.Contains(model.ClientFIO)).Select(x => x.GetViewModel).ToList(); return context.Clients.Where(x => x.Email.Contains(model.Email)).Select(x => x.GetViewModel).ToList();
} }
public List<ClientViewModel> GetFullList() public List<ClientViewModel> GetFullList()

View File

@ -24,12 +24,12 @@ namespace JewelryStoreFileImplement.Implements
} }
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{ {
if (string.IsNullOrEmpty(model.ClientFIO)) if (string.IsNullOrEmpty(model.Email))
{ {
return new(); return new();
} }
return source.Clients return source.Clients
.Where(x => x.ClientFIO.Contains(model.ClientFIO)) .Where(x => x.Email.Contains(model.Email))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -30,13 +30,13 @@ namespace JewelryStoreListImplement.Implements
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{ {
var result = new List<ClientViewModel>(); var result = new List<ClientViewModel>();
if (string.IsNullOrEmpty(model.ClientFIO)) if (string.IsNullOrEmpty(model.Email))
{ {
return result; return result;
} }
foreach (var client in _source.Clients) foreach (var client in _source.Clients)
{ {
if (client.ClientFIO.Contains(model.ClientFIO)) if (client.Email.Contains(model.Email))
{ {
result.Add(client.GetViewModel); result.Add(client.GetViewModel);
} }