public ActionResult DeleteSpamItems(DeleteSpamViewModel model) { var snipKeys = Request.Form.AllKeys.Where(ky => ky.StartsWith("snippet_")).ToArray(); for (int index = 0; index < snipKeys.Length; index++) { snipKeys[index] = snipKeys[index].Replace("snippet_", ""); } var adminBus = new busAdministration(); if (!adminBus.DeleteSnippets(snipKeys)) { ErrorDisplay.ShowError(adminBus.ErrorMessage); } else { ErrorDisplay.ShowMessage(snipKeys.Length + " snippets deleted."); } var busAdmin = new busAdministration(); model.Snippets = busAdmin.GetSpamKeywords(model.SearchTerm); return(View("DeleteSpam", model)); }
public IEnumerable <SpamKeyword> GetSpamKeywords() { if (!this.IsAdmin()) { throw new InvalidOperationException("Access denied."); } var admin = new busAdministration(); return(admin.Context.SpamKeywords.OrderBy(kw => kw.Keyword)); }
public ActionResult ShrinkDataBase() { busAdministration admin = new busAdministration(); if (!admin.ShrinkDatabase()) this.ErrorDisplay.ShowError(admin.ErrorMessage); else this.ErrorDisplay.ShowMessage("Database has been shrunk"); return View("Index", this.ViewModel); }
public ActionResult DeleteSpam(DeleteSpamViewModel model) { if (!string.IsNullOrEmpty(Request.Form["btnDelete"])) { return(DeleteSpamItems(model)); } var busAdmin = new busAdministration(); model.Snippets = busAdmin.GetSpamKeywords(model.SearchTerm); return(View(model)); }
public ActionResult UpdateFormattedCode() { busAdministration admin = new busAdministration(); if (!admin.UpdateFormattedCode()) { ErrorDisplay.ShowError(admin.ErrorMessage); } else { ErrorDisplay.ShowMessage("Snippets have been updated..."); } return(View("Index", ViewModel)); }
public ActionResult ShrinkDataBase() { busAdministration admin = new busAdministration(); if (!admin.ShrinkDatabase()) { ErrorDisplay.ShowError(admin.ErrorMessage); } else { ErrorDisplay.ShowMessage("Database has been shrunk"); } return(View("Index", ViewModel)); }
public bool AddSpamFilter(string keyword) { if (!this.IsAdmin()) { throw new InvalidOperationException("Access denied."); } if (string.IsNullOrEmpty(keyword)) { throw new InvalidOperationException("Can't add a blank keyword"); } var admin = new busAdministration(); admin.AddSpamKeyword(keyword); return(true); }
public bool RemoveSpamKeyword(string keyword) { if (!this.IsAdmin()) { throw new InvalidOperationException("Access denied."); } if (string.IsNullOrEmpty(keyword)) { throw new InvalidOperationException("Can't add a blank keyword"); } var admin = new busAdministration(); if (!admin.RemoveSpamKeyword(keyword)) { throw new InvalidOperationException("Couldn't remove item: " + admin.ErrorMessage); } return(true); }
public ActionResult DatabaseHousekeeping() { busAdministration codeSnippet = CodePasteFactory.GetAdministration(); int result = codeSnippet.DatabaseHouseKeeping(); if (result < 0) { ErrorDisplay.ShowError(codeSnippet.ErrorMessage); } else { if (result < 0) { ErrorDisplay.ShowMessage("Database housekeeping failed: " + codeSnippet.ErrorMessage); } else { ErrorDisplay.ShowMessage((result).ToString() + " snippets have been cleared out."); } } return(View("Index", ViewModel)); }
public ActionResult UpdateFormattedCode() { busAdministration admin = new busAdministration(); if (!admin.UpdateFormattedCode()) this.ErrorDisplay.ShowError(admin.ErrorMessage); else this.ErrorDisplay.ShowMessage("Snippets have been updated..."); return View("Index", this.ViewModel); }
public ActionResult DeleteSpamItems(DeleteSpamViewModel model) { var snipKeys = Request.Form.AllKeys.Where(ky => ky.StartsWith("snippet_")).ToArray(); for (int index = 0; index < snipKeys.Length; index++) { snipKeys[index] =snipKeys[index].Replace("snippet_", ""); } var adminBus = new busAdministration(); if (!adminBus.DeleteSnippets(snipKeys)) this.ErrorDisplay.ShowError(adminBus.ErrorMessage); else this.ErrorDisplay.ShowMessage(snipKeys.Length + " snippets deleted."); var busAdmin = new busAdministration(); model.Snippets = busAdmin.GetSpamKeywords(model.SearchTerm); return this.View("DeleteSpam",model); }
public ActionResult DeleteSpam(DeleteSpamViewModel model) { if (!string.IsNullOrEmpty(Request.Form["btnDelete"])) return DeleteSpamItems(model); var busAdmin = new busAdministration(); model.Snippets = busAdmin.GetSpamKeywords(model.SearchTerm); return View(model); }
public IEnumerable<SpamKeyword> GetSpamKeywords() { if (!this.IsAdmin()) throw new InvalidOperationException("Access denied."); var admin = new busAdministration(); return admin.Context.SpamKeywords.OrderBy(kw => kw.Keyword); }
public bool RemoveSpamKeyword(string keyword) { if (!this.IsAdmin()) throw new InvalidOperationException("Access denied."); if (string.IsNullOrEmpty(keyword)) throw new InvalidOperationException("Can't add a blank keyword"); var admin = new busAdministration(); if (!admin.RemoveSpamKeyword(keyword)) throw new InvalidOperationException("Couldn't remove item: " + admin.ErrorMessage); return true; }
public bool AddSpamFilter(string keyword) { if (!this.IsAdmin()) throw new InvalidOperationException("Access denied."); if (string.IsNullOrEmpty(keyword)) throw new InvalidOperationException("Can't add a blank keyword"); var admin = new busAdministration(); admin.AddSpamKeyword(keyword); return true; }