public ActionResult DeleteFaq(long id) { var gVal = new GenericValidator(); try { if (id < 1) { gVal.Code = -1; gVal.Error = "Invalid selection"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var delStatus = new FaqServices().DeleteFaq(id); if (delStatus < 1) { gVal.Code = -1; gVal.Error = "FAQ could not be deleted. Please try again later."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; gVal.Error = "FAQ Information was successfully deleted"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFaqs() { try { var faqs = new FaqServices().GetFaqs(); return(Json(faqs, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <FaqObject>(), JsonRequestBehavior.AllowGet)); } }
public ActionResult EditFaq(FaqObject faq) { var gVal = new GenericValidator(); try { var stat = ValidateFaq(faq); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_faq"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldfaq = Session["_faq"] as FaqObject; if (oldfaq == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldfaq.CategoryId = faq.CategoryId; oldfaq.Question = faq.Question; oldfaq.Answer = faq.Answer; var docStatus = new FaqServices().UpdateFaq(oldfaq); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "FAQ already exists." : "FAQ information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldfaq.Id; gVal.Error = "FAQ information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "FAQ information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFaqObjects(JQueryDataTableParamModel param) { try { IEnumerable <FaqObject> filteredParentMenuObjects; int countG; var pagedParentMenuObjects = GetFaqs(param.iDisplayLength, param.iDisplayStart, out countG); if (!string.IsNullOrEmpty(param.sSearch)) { filteredParentMenuObjects = new FaqServices().Search(param.sSearch); } else { filteredParentMenuObjects = pagedParentMenuObjects; } if (!filteredParentMenuObjects.Any()) { return(Json(new List <FaqObject>(), JsonRequestBehavior.AllowGet)); } //var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func <FaqObject, string> orderingFunction = (c => c.FaqCategoryName); var sortDirection = Request["sSortDir_0"]; // asc or desc filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction); var displayedPersonnels = filteredParentMenuObjects; var result = from c in displayedPersonnels select new[] { Convert.ToString(c.Id), c.FaqCategoryName, c.Question, c.Answer }; return(Json(new { param.sEcho, iTotalRecords = countG, iTotalDisplayRecords = countG, aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <FaqObject>(), JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFaq(long id) { try { var faq = new FaqServices().GetFaq(id); if (faq == null || faq.Id < 1) { return(Json(new FaqObject(), JsonRequestBehavior.AllowGet)); } Session["_faq"] = faq; return(Json(faq, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new FaqObject(), JsonRequestBehavior.AllowGet)); } }
public ActionResult AddFaq(FaqObject faq) { var gVal = new GenericValidator(); try { var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateFaq(faq); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } faq.LastUpdated = DateTime.Now; var appStatus = new FaqServices().AddFaq(faq); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "FAQ could not be added. Please try again." : "The FAQ Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "FAQ was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "FAQ processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult Faq() { var faqs = new FaqServices().GetFaqs(); return(View(faqs)); }
public NegotiatedContentResult <GetAllResponse> GetAllFAQs(GetFAQRequest request) { GetAllResponse resp = FaqServices.GetAll(request); return(Content(HttpStatusCode.OK, resp)); }