public void DeleteTopic(int id = 0) { try { FaqTopic tmp = new FaqTopic { ID = id }; tmp.Get(); tmp.Delete(); } catch (Exception e) { Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; Response.StatusDescription = e.Message; Response.Write(e.Message); } }
public ActionResult SaveTopic(int id = 0, string topic = "") { FaqTopic new_topic = new FaqTopic(); try { new_topic = new FaqTopic { ID = id, topic = topic }; new_topic.Save(); return RedirectToAction("Index", "FAQManager"); } catch (Exception e) { TempData["topic"] = topic; TempData["error"] = e.Message; return RedirectToAction("EditTopic", "FAQManager", new { id = id }); } }
public ActionResult EditTopic(int id = 0) { // Get the FAQ to be edited FaqTopic topic = new FaqTopic { ID = id }; topic.Get(); ViewBag.topic = topic; try { FaqTopic tmp = (FaqTopic)TempData["topic"]; if (tmp != null) { ViewBag.topic = tmp; } } catch (Exception) { } if (TempData["error"] != null) { ViewBag.error = TempData["error"].ToString(); } return View(); }
/// Function Header******************************************************* /// Function Name: SaveFAQTopicDetails /// Function Type: Function /// Functionality: used to save the details of FAQ topics /// Input: /// Output: /// Return Value: /// Note: /// ********************************************************************* public bool SaveFAQTopicDetails(Entity.FAQTopicInfo oFAQTopicInfo) { using (TLWDALDataContext _db = new TLWDALDataContext()) { bool _blnRetVal = true; var _varFAQTopic = (from _ft in _db.FaqTopics where _ft.chrIsDeleted.Equals('N') && _ft.strFaqTopic.ToLower().Equals(oFAQTopicInfo.StrFaqTopic) select _ft ).ToList(); if (_varFAQTopic.Count > 0) _blnRetVal = false; else { DAL.FaqTopic oFaqTopic = new FaqTopic(); oFaqTopic.strFaqTopic = oFAQTopicInfo.StrFaqTopic; oFaqTopic.dtCreatedOn = DateTime.Now; oFaqTopic.strCreatedBy = oFAQTopicInfo.StrCreatedBy; oFaqTopic.chrIsDeleted = 'N'; _db.FaqTopics.InsertOnSubmit(oFaqTopic); _db.SubmitChanges(); oFaqTopic = null; } _varFAQTopic = null; return _blnRetVal; } }