Esempio n. 1
0
 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."));
     }
 }
Esempio n. 2
0
 //Aux Methods
 private void ValidateFood(long foodId)
 {
     _foodsService.GetFood(foodId);//this already validates and throws exceptions
 }