Добавлен поиск по паролю (кто так вообще делает)
This commit is contained in:
parent
10082f1517
commit
44af2044b6
@ -5,5 +5,6 @@
|
||||
public int? Id { get; set; }
|
||||
public string? ClientFIO { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StoragesContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
@ -15,14 +17,27 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
var clients = context.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
clients = clients.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
if (!model.Email.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.Email == model.Email).ToList();
|
||||
}
|
||||
if (!model.Password.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.Password == model.Password).ToList();
|
||||
}
|
||||
if (!model.ClientFIO.IsNullOrEmpty())
|
||||
{
|
||||
clients = clients.Where(x => x.ClientFIO == model.ClientFIO).ToList();
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
|
@ -19,11 +19,26 @@ namespace SecuritySystemFileImplement.Implements
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
var clients = source.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
clients = clients.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
return source.Clients.Where(x => x.Email.Contains(model.Email)).Select(x => x.GetViewModel).ToList();
|
||||
if (model.Email != null)
|
||||
{
|
||||
clients = clients.Where(x => x.Email == model.Email).ToList();
|
||||
}
|
||||
if (model.Password != null)
|
||||
{
|
||||
clients = clients.Where(x => x.Password == model.Password).ToList();
|
||||
}
|
||||
if (model.ClientFIO != null)
|
||||
{
|
||||
clients = clients.Where(x => x.ClientFIO == model.ClientFIO).ToList();
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
|
@ -24,19 +24,26 @@ namespace SecuritySystemListImplement.Implements
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
var clients = _source.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
clients = clients.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
if (model.Email != null)
|
||||
{
|
||||
if (client.Email.Contains(model.Email))
|
||||
{
|
||||
result.Add(client.GetViewModel);
|
||||
}
|
||||
clients = clients.Where(x => x.Email == model.Email).ToList();
|
||||
}
|
||||
return result;
|
||||
if (model.Password != null)
|
||||
{
|
||||
clients = clients.Where(x => x.Password == model.Password).ToList();
|
||||
}
|
||||
if (model.ClientFIO != null)
|
||||
{
|
||||
clients = clients.Where(x => x.ClientFIO == model.ClientFIO).ToList();
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user