public async Task Ingredients() { RawIngredientsList RawIngs = await _ingredientsProcess.LoadIngredients(); List <SaveIngredientResource> ingredients = _ingredientsProcess.ProcessIngredientData(RawIngs); _ingredientsProcess.SaveIngredients(ingredients); }
public List <SaveIngredientResource> ProcessIngredientData(RawIngredientsList rawIngredientsList) { List <SaveIngredientResource> ingredients = new List <SaveIngredientResource>(); foreach (RawIngredientModel rawIng in rawIngredientsList.Drinks) { ingredients.Add(new SaveIngredientResource() { Name = rawIng.StrIngredient1 }); } return(ingredients); }
public async Task <RawIngredientsList> LoadIngredients() { string url = "https://www.thecocktaildb.com/api/json/v1/1/list.php?i=list"; using (HttpResponseMessage response = await ApiHelper.HttpClient.GetAsync(url)) { if (response.IsSuccessStatusCode) { RawIngredientsList RawIngredients = await response.Content.ReadAsAsync <RawIngredientsList>(); return(RawIngredients); } else { throw new Exception(response.ReasonPhrase); } } }