public IActionResult UpdateFoodInList(int foodItemId, [FromBody] FoodItemViewModel viewModel)
{
if (viewModel == null)
{
return BadRequest();
}
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
FoodItem singleById = _foodRepository.GetSingle(foodItemId);
if (singleById == null)
{
return NotFound();
}
singleById.ItemName = viewModel.ItemName;
FoodItem newFoodItem = _foodRepository.Update(singleById);
_coolMessageHubContext.Clients.All.FoodUpdated(newFoodItem);
return Ok(Mapper.Map<FoodItemViewModel>(newFoodItem));
}