Esempio n. 1
0
        public IActionResult Index()
        {
            var recipeList = _recipeService.GetAll()
                             .Select(recipe => new RecipeListingModel
            {
                // Map details from EF class to ViewModelClass
                Id                = recipe.Id,
                Complexity        = recipe.Complexity,
                Rating            = recipe.Rating,
                PrepRequired      = recipe.PrepRequired,
                Name              = recipe.Name,
                TimeRequired      = recipe.TimeRequired,
                ServingSuggestion = recipe.ServingSuggestion
            });

            var model = new RecipeIndexModel
            {
                Recipes = recipeList
            };

            return(View(model));
        }