ASPNETCoreAngular2Demo.Controller.FoodItemsController.UpdateFoodInList C# (CSharp) Метод

UpdateFoodInList() приватный Метод

private UpdateFoodInList ( int foodItemId, [ viewModel ) : IActionResult
foodItemId int
viewModel [
Результат IActionResult
        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));
        }