)
This commit is contained in:
parent
0870c015f5
commit
a4843554ec
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,16 @@ namespace FlowerShopDatabaseImplement.Implements
|
||||
}
|
||||
public List<ClientViewModel> 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)
|
||||
|
@ -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)
|
||||
|
@ -32,7 +32,7 @@ namespace FlowerShopListImplement.Implements
|
||||
model)
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user