public PartialViewResult ScriptInfo(int id) { Script sc = new Script(); SQL sql = new SQL(); sql.Connect(); sc = sql.ReturnScriptByID(id); sc.InOfDb = sql.ReturnNameOfInstance(sc.InstOfDb.ID); File file = new File(); sc.Content = file.ReturnContentOfScript(sc.Path); sql.Close(); return PartialView("_ScriptInfo", sc); }
//edytcja skryptu Account public string EditScript(Script sc) { SQL sql = new SQL(); sql.Connect(); Script script = sql.ReturnScriptByID(sc.ID); script.Content = sc.Content; if (script.CheckDate())//jesli true to daty sie zgadzaja { script.Version += 1; //instrukcja dla nadania wersji i unikalnej nazwy script.CreateUniqueName(); while(sql.CheckUniqueName(script.UniqueName)) { script.Version += 1; script.CreateUniqueName(); } script.DateOfCreate = DateTime.Now; } else { script.Version = 0; script.CreateUniqueName(); while (sql.CheckUniqueName(script.UniqueName)) { script.Version += 1; script.CreateUniqueName(); } script.DateOfCreate = DateTime.Now; } if (sql.EditScript(script)) { sql.Close(); return "Edytowano pomyślnie: " + script.UniqueName; } else { sql.Close(); return "Nie udało się."; } }
//usuwanie skryptu public ActionResult RemoveScript(int id) { Script sc = new Script(); SQL sql = new SQL(); sql.Connect(); sc = sql.ReturnScriptByID(id); sql.DeleteScriptFromList(sc.ID); File f = new File(); f.RemoveFile(sc.Path); sql.DeleteScriptFromScript(sc.ID); //AccountVM vm = new AccountVM(User.Identity.Name); User user = sql.ReturnUserByName(User.Identity.Name); AccountVM vm = new AccountVM(user); sql.Close(); return View("Account", vm); }