コード例 #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;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
        // 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);
        }