public ActionResult <FoodModel> GetFood(long foodId) { try { var food = _foodsService.GetFood(foodId); return(Ok(food)); } catch (NotFoundItemException ex) { return(NotFound(ex.Message)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Something unexpected happened.")); } }
//Aux Methods private void ValidateFood(long foodId) { _foodsService.GetFood(foodId);//this already validates and throws exceptions }