Merge branch 'lab5_base' into lab5_hard
This commit is contained in:
commit
918e60384b
@ -32,16 +32,25 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return source.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
return source.Clients
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Email) && x.Email ==
|
||||
model.Email) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
if (model.Email != null && model.Password != null)
|
||||
{
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
if (model.Email != null)
|
||||
{
|
||||
return source.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
@ -51,7 +60,7 @@ namespace FurnitureAssemFileImplement.Implements
|
||||
return new();
|
||||
}
|
||||
return source.Clients
|
||||
.Where(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
|
||||
.Where(x => x.Email.Equals(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -28,27 +28,37 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Clients
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
if (model.Email != null && model.Password != null)
|
||||
{
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
if (model.Email != null)
|
||||
{
|
||||
return context.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) || string.IsNullOrEmpty(model.Password))
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.Email.Equals(model.Email) && x.Password.Equals(model.Password))
|
||||
.Where(x => x.Email.Equals(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -32,15 +32,22 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.Email) && client.Email == model.Email)
|
||||
|| (model.Id.HasValue && client.Id == model.Id))
|
||||
if (model.Id.HasValue && client.Id == model.Id)
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password)
|
||||
&& client.Email.Equals(model.Email) && client.Password.Equals(model.Password))
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Email)
|
||||
&& client.Email.Equals(model.Email))
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
@ -57,7 +64,7 @@ namespace FurnitureAssemblyListImplement.Implements
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Email.Equals(model.Email) && client.Password.Equals(model.Password))
|
||||
if (client.Email.Equals(model.Email))
|
||||
{
|
||||
result.Add(client.GetViewModel);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user