Esempio n. 1
0
        public async Task <IActionResult> Edit(GruntTaskModel taskModel)
        {
            try
            {
                GruntTask task = new GruntTask
                {
                    Id            = taskModel.Id,
                    Name          = taskModel.Name,
                    Description   = taskModel.Description,
                    Help          = taskModel.Help,
                    Code          = taskModel.Code,
                    UnsafeCompile = taskModel.UnsafeCompile,
                    TokenTask     = taskModel.TokenTask,
                    Options       = taskModel.Options
                };
                taskModel.ReferenceSourceLibraries.ForEach(async RSL => {
                    task.Add(await _context.GetReferenceSourceLibrary(RSL));
                });
                taskModel.ReferenceAssemblies.ForEach(async RA => {
                    task.Add(await _context.GetReferenceAssembly(RA));
                });
                taskModel.EmbeddedResources.ForEach(async ER => {
                    task.Add(await _context.GetEmbeddedResource(ER));
                });
                ViewBag.ReferenceSourceLibraries = await _context.GetReferenceSourceLibraries();

                ViewBag.ReferenceAssemblies = await _context.GetReferenceAssemblies();

                ViewBag.EmbeddedResources = await _context.GetEmbeddedResources();

                return(View(await _context.EditGruntTask(task)));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                return(RedirectToAction(nameof(Edit), new { Id = taskModel.Id }));
            }
        }