Esempio n. 1
0
 public static Script CreateScript(PowerShellViewModel vm, string userName)
 {
     //Auto Mapper
     Mapper.CreateMap<PowerShellViewModel, Script>();
     var script = Mapper.Map<PowerShellViewModel, Script>(vm);
     script.Author = userName;
     return script;
 }
 public ActionResult Edit(PowerShellViewModel vmScript)
 {
     //For now - only editning the file - will need to allow for renames
     if (ScriptIO.Write(vmScript.Name, vmScript.Script))
     {
         return RedirectToAction("Details", new { id = vmScript.Id });
     }
     return View(vmScript);
 }
        // GET: PowerShell/Edit/5
        public ActionResult Edit(int id)
        {
            var script = _scriptRepository.GetScriptById(id);
            if (script == null) { return RedirectToAction("Index"); }

            var scriptContents = ScriptIO.Read(script.Name);

            var scriptView = new PowerShellViewModel()
            {
                Id = script.Id,
                Name = script.Name,
                Script = scriptContents
            };
            return View(scriptView);
        }