public ActionResult InstallPackageDetailsPOST(PackagingInstallViewModel packagingInstallViewModel, string redirectUrl)
        {
            if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                if (_recipeHarvester != null && _recipeManager != null)
                {
                    IEnumerable <Recipe> recipes = _recipeHarvester.HarvestRecipes(packagingInstallViewModel.ExtensionDescriptor.Id)
                                                   .Where(loadedRecipe => packagingInstallViewModel.Recipes.FirstOrDefault(recipeViewModel => recipeViewModel.Execute && recipeViewModel.Recipe.Name.Equals(loadedRecipe.Name)) != null);

                    foreach (Recipe recipe in recipes)
                    {
                        try {
                            _recipeManager.Execute(recipe);
                        }
                        catch {
                            Services.Notifier.Error(T("Recipes contains {0} unsupported module installation steps.", recipe.Name));
                        }
                    }
                }

                // Enable selected features
                if (packagingInstallViewModel.Features.Count > 0)
                {
                    IEnumerable <string> featureIds = packagingInstallViewModel.Features
                                                      .Where(feature => feature.Enable)
                                                      .Select(feature => feature.FeatureDescriptor.Id);

                    // Enable the features and its dependencies using recipes, so that they are run after the module's recipes

                    var recipe = new Recipe {
                        Name        = "Test",
                        RecipeSteps = featureIds.Select(
                            (i, x) => new RecipeStep(
                                id: i.ToString(CultureInfo.InvariantCulture),
                                recipeName: "Test",
                                name: "Feature",
                                step: new XElement("Feature", new XAttribute("enable", x))))
                    };

                    _recipeManager.Execute(recipe);
                }
            } catch (Exception exception) {
                Services.Notifier.Error(T("Post installation steps failed with error: {0}", exception.Message));
            }

            return(Redirect(redirectUrl));
        }
        public ActionResult InstallPackageDetailsPOST(PackagingInstallViewModel packagingInstallViewModel, string redirectUrl)
        {
            if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                IEnumerable <Recipe> recipes = _recipeHarvester.HarvestRecipes(packagingInstallViewModel.ExtensionDescriptor.Id)
                                               .Where(loadedRecipe => packagingInstallViewModel.Recipes.FirstOrDefault(recipeViewModel => recipeViewModel.Execute && recipeViewModel.Recipe.Name.Equals(loadedRecipe.Name)) != null);

                foreach (Recipe recipe in recipes)
                {
                    try {
                        _recipeManager.Execute(recipe);
                    }
                    catch {
                        Services.Notifier.Error(T("Recipes contains {0} unsuported module installation steps.", recipe.Name));
                    }
                }

                // Enable selected features
                if (packagingInstallViewModel.Features.Count > 0)
                {
                    IEnumerable <string> featureIds = packagingInstallViewModel.Features
                                                      .Where(feature => feature.Enable)
                                                      .Select(feature => feature.FeatureDescriptor.Id);

                    // Enable the features and its dependencies
                    _moduleService.EnableFeatures(featureIds, true);
                }
            } catch (Exception exception) {
                Services.Notifier.Error(T("Post installation steps failed with error: {0}", exception.Message));
            }

            return(Redirect(redirectUrl));
        }