I have this view model that list some food in data base ,
public async Task<IActionResult> FilterFoodList(FilterFoodViewModel filterFoodViewModel )
{
var result = await _foodService.FilterFoodList(filterFoodViewModel);
return View(result);
}
food have relation with FoodCategory and FoodSelectedcategory
and have access to them
How can I show FoodCategory for each food in view
I try it but can not:
<td>
@if (!string.IsNullOrEmpty(food.FoodTitle))
{
var category = Model.FoodCategories.FirstOrDefault(c => c.FoodCategoryId == food.FoodId);
if (category != null)
{
<span>@category.FoodCategoryTitle</span>
}
}
</td>