Важное исправление
This commit is contained in:
parent
c823a62a24
commit
9c4bb0ad59
@ -10,26 +10,40 @@ namespace HospitalDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public ApothecaryViewModel? GetElement(ApothecarySearchModel model)
|
public ApothecaryViewModel? GetElement(ApothecarySearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue && string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new HospitalDatabase();
|
using var context = new HospitalDatabase();
|
||||||
return context.Apothecaries.FirstOrDefault(x =>
|
|
||||||
(!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) ||
|
if (model.Id.HasValue)
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
{
|
||||||
?.GetViewModel;
|
return context.Apothecaries.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Login != null && model.Password != null)
|
||||||
|
{
|
||||||
|
return context.Apothecaries
|
||||||
|
.FirstOrDefault(x => x.Login.Equals(model.Login) && x.Password.Equals(model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.Login != null)
|
||||||
|
return context.Apothecaries.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApothecaryViewModel> GetFilteredList(ApothecarySearchModel model)
|
public List<ApothecaryViewModel> GetFilteredList(ApothecarySearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Login) || string.IsNullOrEmpty(model.Password))
|
if (string.IsNullOrEmpty(model.Login))
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new HospitalDatabase();
|
using var context = new HospitalDatabase();
|
||||||
return context.Apothecaries
|
return context.Apothecaries
|
||||||
.Where(x => x.Login.Equals(model.Login) && x.Password.Equals(model.Password))
|
.Where(x => x.Login.Equals(model.Login))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user