private void CheckUrlParams() { string[] path = Request.Path.Split('/'); if (path.Length == 4) { string category = path[2].Replace("_", " "); string question = path[3].Replace("_", " "); faqView.SetActiveView(vQuestion); var faq = SnitzFaq.GetQuestion(String.Format("/{0}/{1}", category, question), "").ToList(); if (faq.Count() == 1 && faq[0] != null) { fvQuestion.Text = string.Format("<h1>{0}?</h1>", question); fvAnswer.Text = faq[0].LinkBody.ReplaceNoParseTags(); hdnFaqId.Value = faq[0].Id.ToString(); } btnDeleteFaq.OnClientClick = "confirmPostBack('Do you want to delete Question and answer?','Delete'," + hdnFaqId.Value + ");return false;"; btnEdit.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); btnDeleteFaq.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); } else { faqView.SetActiveView(vDefault); hdnFaqId.Value = "-1"; } }
protected void BindQuestions(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { FaqCategoryInfo cat = (FaqCategoryInfo)e.Item.DataItem; if (!String.IsNullOrEmpty(cat.Roles) && !Roles.IsUserInRole(cat.Roles) && !IsAdministrator) { e.Item.Visible = false; return; } int id = 0; if (e.Item.FindControl("hdnCatId") != null) { id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hdnCatId")).Value); } if (e.Item.FindControl("FaqQuestions") != null) { Repeater fqr = ((Repeater)e.Item.FindControl("FaqQuestions")); if (fqr != null) { if (!String.IsNullOrEmpty(Filter)) { fqr.DataSource = SnitzFaq.FindFaqQuestion(Filter, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); } else { fqr.DataSource = SnitzFaq.GetFaqQuestionsByCategory(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); } fqr.DataBind(); } } } }
protected void AddNewQuestion(object sender, EventArgs e) { if (tbxQuestion.Text == "" || tbxAnswer.Text == "") { return; } if (hdnEditFaq.Value != "") { currentfaq = Convert.ToInt32(hdnEditFaq.Value); if (currentfaq > 0) { SaveFAQ(sender, e); } } string category = ddlCategory.SelectedValue; string question = tbxQuestion.Text; string answer = tbxAnswer.Text; FaqInfo faq = new FaqInfo { CatId = Convert.ToInt32(category), Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName, Link = String.Empty, LinkTitle = question, LinkBody = answer, Order = tbxQorder.Text == "" ? 0 : Convert.ToInt32(tbxQorder.Text) }; SnitzFaq.AddFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
protected void SelectCategory(object sender, EventArgs e) { FaqCategoryInfo cat = SnitzFaq.GetCategory(ddlCategoryEdit.SelectedItem.Text); if (cat != null) { if (currentfaq == cat.Id) { return; } currentfaq = cat.Id; catDescription.Text = cat.Description; catLang.Text = cat.Language; catOrder.Text = cat.Order.ToString(); catRole.Text = cat.Roles; } else { currentfaq = -1; catDescription.Text = ""; catLang.Text = "en"; catOrder.Text = "99"; catRole.Text = ""; } }
private void DeleteFaq(int id) { int question = id; SnitzFaq.DeleteFaqQuestion(question); BindFaqNav(); }
protected void Delete(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(hdnFaqId.Value); if (id > 0) { SnitzFaq.DeleteFaqQuestion(id); Response.Redirect("/Faq"); } }
protected void ToggleEdit(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(faqId.Value); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faqId.Value = id.ToString(); tbxQuestion.Text = faq.LinkTitle; tbxAnswer.Text = faq.LinkBody; FaqViews.ActiveViewIndex = 1; hdnEditFaq.Value = id.ToString(); tbxQorder.Text = faq.Order.ToString(); ddlCategory.SelectedValue = faq.CatId.ToString(); }
protected void ViewAnswer(object source, RepeaterCommandEventArgs e) { int question = Convert.ToInt32(e.CommandArgument); faqId.Value = question.ToString(); FaqInfo faq = SnitzFaq.GetFaqQuestion(question, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faqQuestion.Text = "<h1>" + faq.LinkTitle + "</h1>"; faqAnswer.Text = faq.LinkBody.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); btnDeleteFaq.OnClientClick = "confirmPostBack('Do you want to delete Question and answer?','DeleteFaq'," + faqId.Value + ");return false;"; btnEdit.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); btnDeleteFaq.Visible = IsAdministrator || Roles.IsUserInRole("FAQEditor"); }
protected void DeleteCat(object sender, ImageClickEventArgs e) { FaqCategoryInfo cat = SnitzFaq.GetCategory(fcCategory.SelectedItem.Text); if (cat != null) { var questions = SnitzFaq.GetFaqQuestionsByCategory(cat.Id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); if (!questions.Any()) { SnitzFaq.DeleteFaqCategory(cat); //refresh the category cache Cache.Remove("faqcatlist"); Response.Redirect(this.Request.RawUrl); } } }
protected void SelectCategory(object sender, EventArgs e) { FaqCategoryInfo cat = SnitzFaq.GetCategory(fcCategory.SelectedItem.Text); if (cat != null) { fcTitle.Text = cat.Description; fcRoles.Text = cat.Roles; fcLang.Text = cat.Language; fcOrder.Text = cat.Order.ToString(); } else { fcTitle.Text = ""; fcLang.Text = "en"; fcOrder.Text = "99"; fcRoles.Text = ""; } }
private void SaveFAQ(object sender, EventArgs eventArgs) { int id = Convert.ToInt32(hdnEditFaq.Value); string category = ddlCategory.SelectedValue; string question = tbxQuestion.Text; string answer = tbxAnswer.Text; int order = tbxQorder.Text == "" ? 0 : Convert.ToInt32(tbxQorder.Text); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faq.Order = order; faq.CatId = Convert.ToInt32(category); faq.LinkTitle = question; faq.LinkBody = answer; SnitzFaq.UpdateFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
protected void Save(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(hdnFaqId.Value); string category = feCategory.SelectedValue; string question = feTitle.Text; string answer = feBody.Text; int order = feOrder.Text == "" ? 0 : Convert.ToInt32(feOrder.Text); FaqInfo faq = SnitzFaq.GetFaqQuestion(id, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); faq.Order = order; faq.CatId = Convert.ToInt32(category); faq.Link = String.Format("/{0}/{1}", feCategory.SelectedItem.Text, question); faq.LinkTitle = question; faq.LinkBody = answer; SnitzFaq.UpdateFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }
protected void SaveCat(object sender, ImageClickEventArgs e) { FaqCategoryInfo cat = SnitzFaq.GetCategory(fcTitle.Text) ?? new FaqCategoryInfo(); cat.Description = fcTitle.Text; cat.Order = Convert.ToInt32(fcOrder.Text); cat.Roles = fcRoles.Text; cat.Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; if (cat.Id > 0) { SnitzFaq.UpdateFaqCategory(cat); } else { SnitzFaq.AddFaqCategory(cat); } //refresh the category cache Cache.Remove("faqcatlist"); Response.Redirect(this.Request.RawUrl); }
protected void AddNewCategory(object sender, EventArgs e) { FaqCategoryInfo cat = SnitzFaq.GetCategory(catDescription.Text) ?? new FaqCategoryInfo(); cat.Description = catDescription.Text; cat.Order = Convert.ToInt32(catOrder.Text); cat.Roles = catRole.Text; cat.Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; if (cat.Id > 0) { SnitzFaq.UpdateFaqCategory(cat); } else { SnitzFaq.AddFaqCategory(cat); } SetDefaultView(); //refresh the category cache Cache.Remove("faqcatlist"); Response.Redirect(this.Request.RawUrl); }
protected void ToggleEdit(object sender, ImageClickEventArgs e) { faqView.SetActiveView(vEdit); string[] path = Request.Path.Split('/'); if (path.Length == 4) { string category = path[2].Replace("_", " "); string question = path[3].Replace("_", " "); var faq = SnitzFaq.GetQuestion(String.Format("/{0}/{1}", category, question), "").ToList(); if (faq.Count() == 1) { feCategory.SelectedValue = faq[0].CatId.ToString(); feTitle.Text = question; feOrder.Text = faq[0].Order.ToString(); feBody.Text = faq[0].LinkBody; hdnFaqId.Value = faq[0].Id.ToString(); } } }
protected void Add(object sender, ImageClickEventArgs e) { if (fnTitle.Text == "" || fnBody.Text == "") { return; } string category = fnCategory.SelectedValue; string question = fnTitle.Text; string answer = fnBody.Text; FaqInfo faq = new FaqInfo { CatId = Convert.ToInt32(category), Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName, Link = String.Format("/{0}/{1}", fnCategory.SelectedItem.Text, question), LinkTitle = question, LinkBody = answer, Order = fnOrder.Text == "" ? 0 : Convert.ToInt32(fnOrder.Text) }; SnitzFaq.AddFaqQuestion(faq); Response.Redirect(this.Request.RawUrl); }