Esempio n. 1
0
        public async Task <IActionResult> Index(int pageNumber)
        {
            var model = new RecipeSearchViewModel();

            model.Recipes = new List <Result>();

            var response = await _RecipeClient.GetAllRecipes(pageNumber);



            foreach (var recipe in response.results)
            {
                model.Recipes.Add(recipe);
            }

            model.currentPageNumber  = pageNumber;
            model.nextPageNumber     = pageNumber + 1;
            model.previousPageNumber = pageNumber - 1;

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> RecipeIndexResult(RecipeSearchViewModel model)
        {
            var response = await _recipeClient.GetAllRecipes(model.ingredient, model.title, model.page);

            var viewModel = new RecipeIndexViewModel();

            viewModel.results = response.results
                                .Select(response => new ResultsViewModel()
            {
                title = response.title, href = response.href, thumbnail = response.thumbnail
            })
                                .ToList();

            return(View(viewModel));
        }