вот теперь работает

This commit is contained in:
ityurner02@mail.ru 2023-04-17 18:18:07 +04:00
parent 04daacfad4
commit 163e5f614b
2 changed files with 14 additions and 20 deletions

View File

@ -26,23 +26,18 @@ namespace PlumbingRepairDatabaseImplement.Implements
public ImplementerViewModel? GetElement(ImplementerSearchModel model) public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{ {
if (string.IsNullOrEmpty(model.ImplementerFIO) &&
string.IsNullOrEmpty(model.Password) &&
!model.Id.HasValue)
{
return null;
}
using var context = new PlumbingRepairDataBase(); using var context = new PlumbingRepairDataBase();
if (model.Id.HasValue)
{
return context.Implementers return context.Implementers
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel; .FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
} (string.IsNullOrEmpty(model.Password) || x.Password == model.Password) &&
else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password)) (!model.Id.HasValue || x.Id == model.Id))
{ ?.GetViewModel;
return context.Implementers
.FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password))?.GetViewModel;
}
else if (!string.IsNullOrEmpty(model.ImplementerFIO))
{
return context.Implementers
.FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO))?.GetViewModel;
}
return new();
} }
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model) public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)

View File

@ -86,10 +86,9 @@ namespace PlumbingRepairDatabaseImplement.Implements
.Include(x => x.Work) .Include(x => x.Work)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .Include(x => x.Implementer)
.FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status == x.Status) && .FirstOrDefault(x => (!model.ImplementerId.HasValue || x.ImplementerId == model.ImplementerId) &&
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || (!model.Status.HasValue || x.Status == model.Status) &&
model.Id.HasValue && x.Id == model.Id) (!model.Id.HasValue || x.Id == model.Id))?.GetViewModel;
?.GetViewModel;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)