Example #1
0
        public async Task <IActionResult> Display(int id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan))
            {
                return(Forbid());
            }

            var deploymentPlan = await _session.GetAsync <DeploymentPlan>(id);

            if (deploymentPlan == null)
            {
                return(NotFound());
            }

            var items = new List <dynamic>();

            foreach (var step in deploymentPlan.DeploymentSteps)
            {
                dynamic item = await _displayManager.BuildDisplayAsync(step, _updateModelAccessor.ModelUpdater, "Summary");

                item.DeploymentStep = step;
                items.Add(item);
            }

            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var factory in _factories)
            {
                var     step      = factory.Create();
                dynamic thumbnail = await _displayManager.BuildDisplayAsync(step, _updateModelAccessor.ModelUpdater, "Thumbnail");

                thumbnail.DeploymentStep = step;
                thumbnails.Add(factory.Name, thumbnail);
            }

            var model = new DisplayDeploymentPlanViewModel
            {
                DeploymentPlan = deploymentPlan,
                Items          = items,
                Thumbnails     = thumbnails,
            };

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> Display(int id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan))
            {
                return(Unauthorized());
            }

            var deploymentPlan = await _session.GetAsync <DeploymentPlan>(id);

            if (deploymentPlan == null)
            {
                return(NotFound());
            }

            var items = new List <dynamic>();

            foreach (var step in deploymentPlan.DeploymentSteps)
            {
                var item = await _displayManager.DisplayStepAsync(step, this, "Summary");

                items.Add(item);
            }

            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var driver in _drivers)
            {
                var thumbnail = await _displayManager.DisplayStepAsync(driver.Create(), this, "Thumbnail");

                thumbnails.Add(driver.Type.Name, thumbnail);
            }

            var model = new DisplayDeploymentPlanViewModel
            {
                DeploymentPlan = deploymentPlan,
                Items          = items,
                Thumbnails     = thumbnails,
            };

            return(View(model));
        }