This commit is contained in:
Николай 2023-03-11 19:28:29 +04:00
parent da162462b5
commit 5dbea38023
2 changed files with 4 additions and 9 deletions

View File

@ -24,10 +24,8 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
public List<DishViewModel>? ReadList(DishSearchModel? model)
{
_logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}",
model?.DishName, model?.Id);
var list = model == null ? _dishStorage.GetFullList() :
_dishStorage.GetFilteredList(model);
_logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", model?.DishName, model?.Id);
var list = model == null ? _dishStorage.GetFullList() : _dishStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");

View File

@ -22,8 +22,7 @@ namespace FoodOrdersListImplement.Implements
}
return result;
}
public List<DishViewModel> GetFilteredList(DishSearchModel
model)
public List<DishViewModel> GetFilteredList(DishSearchModel model)
{
var result = new List<DishViewModel>();
if (string.IsNullOrEmpty(model.DishName))
@ -47,9 +46,7 @@ namespace FoodOrdersListImplement.Implements
}
foreach (var dish in _source.Dish)
{
if ((!string.IsNullOrEmpty(model.DishName) &&
dish.DishName == model.DishName) ||
(model.Id.HasValue && dish.Id == model.Id))
if ((!string.IsNullOrEmpty(model.DishName) && dish.DishName == model.DishName) || (model.Id.HasValue && dish.Id == model.Id))
{
return dish.GetViewModel;
}