Exemple #1
0
        public IActionResult Index()
        {
            var viewModel = new HomeViewModel
            {
                Recipes = _recipesService.GetAll()
            };

            return(View(viewModel));
        }
Exemple #2
0
 public ApplicationViewModel(IRecipesService recipesService, IProductNutrientsService productNutrientsService,
                             INutrientComponentsService nutrientComponentsService)
 {
     _recipesService            = recipesService;
     _productNutrientsService   = productNutrientsService;
     _nutrientComponentsService = nutrientComponentsService;
     AllRecipes    = new ObservableCollection <Recipe>(_recipesService.GetAll());
     ChosenRecipes = new ObservableCollection <Recipe>();
 }
        public async Task <IActionResult> GetAll()
        {
            var recipes     = _recipesService.GetAll();
            var model       = _mapper.Map <IList <RecipeModel> >(recipes);
            var accessToken = Request.Headers["Authorization"].ToString();

            foreach (var recipe in model)
            {
                var calories = 0;
                foreach (var ingredientModel in recipe.Ingredients)
                {
                    var ingredient = _mapper.Map <Ingredient>(ingredientModel);
                    calories += await _ingredientService.GetIngredientCaloriesByName(ingredient, accessToken);
                }
                recipe.Calories = calories;
            }
            return(Ok(model));
        }
        public async Task <IActionResult> GetAll([FromQuery] GetRecipesRequest request)
        {
            var vm = await _recipesService.GetAll(request);

            return(Ok(vm));
        }
Exemple #5
0
        public async Task <IActionResult> GetRecipeList()
        {
            var allRecipes = await _recipesService.GetAll();

            return(Ok(allRecipes));
        }