Exemplo n.º 1
0
        public async Task <Meal> GetMealById(int MealId)
        {
            Meal Meal = null;
            HttpResponseMessage response = await new HttpClient()
                                           .GetAsync(BaseURL + "Meal/" + MealId);

            if (response.IsSuccessStatusCode)
            {
                ReceivedAPIMeal APIMeal = await response.Content.ReadAsAsync <ReceivedAPIMeal>();

                Meal = new Meal()
                {
                    Name      = APIMeal.Name,
                    StarterId = APIMeal.StarterId,
                    Starter   = await GetDishById(APIMeal.StarterId),
                    MainId    = APIMeal.MainId,
                    Main      = await GetDishById(APIMeal.MainId),
                    DessertId = APIMeal.DessertId,
                    Dessert   = await GetDishById(APIMeal.DessertId),
                    Id        = APIMeal.Id
                };
            }

            return(Meal);
        }
Exemplo n.º 2
0
 public async Task <Meal> GetMealByAPIMeal(ReceivedAPIMeal APIMeal)
 {
     return(new Meal()
     {
         Name = APIMeal.Name,
         StarterId = APIMeal.StarterId,
         Starter = await GetDishById(APIMeal.StarterId),
         MainId = APIMeal.MainId,
         Main = await GetDishById(APIMeal.MainId),
         DessertId = APIMeal.DessertId,
         Dessert = await GetDishById(APIMeal.DessertId),
         Id = APIMeal.Id
     });
 }