Исправлено

This commit is contained in:
Павел Сорокин 2023-03-24 19:08:57 +04:00
parent b3d8a1a402
commit ea4fca8e42

View File

@ -43,14 +43,18 @@ namespace ShipyardDataBaseImplement.Implements
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
{
return null;
}
using var context = new ShipyardDataBase();
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;
}
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
{
return context.Clients
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel;
}
return new();
}
public ClientViewModel? Insert(ClientBindingModel model)