public bool Insert(Guid websiteId, FAQ.DataStructure.FAQ faq, FAQContent faqContent, HttpPostedFileBase image) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FaqConnection.StartTransaction(IsolationLevel.ReadUncommitted); faq.IsExternal = true; if (!FAQComponent.Instance.FAQTransactionalFacade(this.FaqConnection).Insert(faq, faqContent, image)) { throw new Exception("خطایی در ذخیره FAQ وجود دارد"); } var congressFaq = new WebDesign.DataStructure.FAQ { FAQId = faq.Id, WebId = websiteId }; if (!new FAQBO().Insert(this.ConnectionHandler, congressFaq)) { throw new Exception("خطایی در ذخیره FAQ وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.FaqConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.FaqConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FaqConnection.RollBack(); throw new KnownException(ex.Message, ex); } }
public static FAQContent Content(this FAQ.DataStructure.FAQ faq, string culture) { var content = new FAQContentFacade().Get(faq.Id, culture); if (content != null) { if (content.Question != null) { content.Question = content.Question.Replace("\r\n", "<br />"); } return(content); } content = new FAQContent { Id = faq.Id, Answer = faq.Answer, Question = faq.Question, }; return(content); }
public bool Insert(Guid congressId, FAQ.DataStructure.FAQ faq, FAQContent faqContent, HttpPostedFileBase image) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FaqConnection.StartTransaction(IsolationLevel.ReadUncommitted); faq.IsExternal = true; if (!FAQComponent.Instance.FAQTransactionalFacade(this.FaqConnection).Insert(faq, faqContent, image)) { throw new Exception(Resources.Congress.ErrorInInsertFAQ); } var congressFaq = new CongressFAQ { FAQId = faq.Id, CongressId = congressId }; if (!new CongressFAQBO().Insert(this.ConnectionHandler, congressFaq)) { throw new Exception(Resources.Congress.ErrorInDeleteCongressFAQ); } this.ConnectionHandler.CommitTransaction(); this.FaqConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FaqConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FaqConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }