Agliullov D. A. Lab Work 5 Hard #16
@ -26,7 +26,16 @@ namespace ConfectioneryFileImplement
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
return _source.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.Id.HasValue)
|
||||
return _source.Clients.FirstOrDefault(x => 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)
|
||||
|
@ -30,7 +30,16 @@ namespace ConfectioneryListImplement
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
return _source.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
if (model.Id.HasValue)
|
||||
return _source.Clients.FirstOrDefault(x => 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)
|
||||
|
@ -11,5 +11,7 @@ namespace ConfectioneryContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,16 @@ namespace ConfectioneryDatabaseImplement.Implements
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
using var context = new ConfectioneryDatabase();
|
||||
return context.Clients.FirstOrDefault(x => 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)
|
||||
|
Loading…
Reference in New Issue
Block a user