public ActionResult Delete(string preset_id) { if (Session["LoggedIn"] != null) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); try { var query = (from preset1 in db.presets where preset1.pre_id == int.Parse(preset_id) select preset1).Single(); db.presets.DeleteOnSubmit(query); db.SubmitChanges(); } catch { return RedirectToAction("Index"); } db.Connection.Close(); return RedirectToAction("Index",Random.Equals(3,10)); } else { return RedirectToAction("ShowLogin","Home"); } }
public ActionResult ChangePassword(string pwdCurrent, string pwdNew, string pwdRepeat) { if (Session["LoggedIn"] != null) { /* SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from set1 in db.settings select set1).Single(); query.lookup_time = int.Parse(set); db.SubmitChanges(); db.Connection.Close(); */ if (pwdNew != pwdRepeat) { return RedirectToAction("Index", "Settings", new { message = "The passwords you entered did not match!", msgType = "error" }); } if (pwdNew.Length < 6) { return RedirectToAction("Index", "Settings", new { message = "Please enter a password of minimum 6 characters!", msgType = "error" }); } if (pwdNew.Length > 50) { return RedirectToAction("Index", "Settings", new { message = "The password is too long. Please enter a password that you can remember.", msgType = "error" }); } SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from pass1 in db.users select pass1).Single(); if (query.password != pwdCurrent) { db.Connection.Close(); return RedirectToAction("Index", "Settings", new { message = "Please enter the correct current password.", msgType = "error" }); } query.password = pwdNew; db.SubmitChanges(); db.Connection.Close(); return RedirectToAction("Index", "Settings", new { message = "The password was successfully changed.", msgType = "success" }); } else { return RedirectToAction("ShowLogin","Home"); } }
public ActionResult Delete(string desc_id) { if (Session["LoggedIn"] != null) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from details in db.intrusions where details.int_id == int.Parse(desc_id) select details).Single(); db.intrusions.DeleteOnSubmit(query); db.SubmitChanges(); db.Connection.Close(); return RedirectToAction("Index"); } else { return RedirectToAction("ShowLogin","Home"); } }
public ActionResult Tracking(string set) { if (Session["LoggedIn"] != null) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from set1 in db.settings select set1).Single(); query.int_tracking = int.Parse(set); db.SubmitChanges(); db.Connection.Close(); return RedirectToAction("Index",Random.Equals(3,10)); } else { return RedirectToAction("ShowLogin","Home"); } }
/// <summary> /// Stop the Surveillance /// </summary> public ActionResult Stop() { if (Session["LoggedIn"] != null) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from status in db.camStatus select status).Single(); query.surveillance = 0; db.SubmitChanges(); db.Connection.Close(); return RedirectToAction("Index"); } else { return RedirectToAction("ShowLogin","Home"); } }
public ActionResult Save(string preset_name) { if (Session["LoggedIn"] != null) { if (preset_name != null && preset_name.Length>0) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from stat in db.camStatus select stat).Single(); preset mypreset = new preset { pre_name = preset_name, cam_x = query.cam_x, cam_y = query.cam_y, cam_z = query.cam_z, }; db.presets.InsertOnSubmit(mypreset); db.SubmitChanges(); db.Connection.Close(); } return RedirectToAction("Index"); } else { return RedirectToAction("ShowLogin","Home"); } }
/// <summary> /// Loads a predefined camera configuration /// </summary> public ActionResult Load(string preset_id) { if (Session["LoggedIn"] != null) { SpaceLockLSDataContext db = new SpaceLockLSDataContext(); var query = (from status in db.camStatus select status).Single(); query.pre_id = int.Parse(preset_id); db.SubmitChanges(); db.Connection.Close(); return RedirectToAction("Index"); } else { return RedirectToAction("ShowLogin","Home"); } }