public override bool Delete(params object[] keys) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var faq = new FAQBO().Get(this.ConnectionHandler, keys); if (faq == null) { return(true); } var list = new FAQContentBO().Where(this.ConnectionHandler, content => content.Id == faq.Id); foreach (var content in list) { if (!new FAQContentBO().Delete(this.ConnectionHandler, content.Id, content.LanguageId)) { throw new Exception("خطایی در حذف محتوا وجود دارد"); } } if (faq.ThumbnailId.HasValue) { if ( !FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Delete(faq.ThumbnailId.Value)) { throw new Exception("Could not delete Thumbnail."); } } if (!new FAQBO().Delete(this.ConnectionHandler, keys)) { throw new Exception("خطایی در حذف محتوا وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool Update(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnection, DataStructure.FAQ obj, FAQContent faqContent, HttpPostedFileBase image) { if (image != null) { var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(filemanagerconnection); if (obj.ThumbnailId.HasValue) { fileTransactionalFacade.Update(image, obj.ThumbnailId.Value); } else { obj.ThumbnailId = fileTransactionalFacade.Insert(image); } } if (!this.Update(connectionHandler, obj)) { throw new Exception("خطایی در ویرایش محتوای FAQ وجود دارد"); } if (faqContent == null) { return(true); } var faqContentBo = new FAQContentBO(); if (faqContent.Id == Guid.Empty) { faqContent.Id = obj.Id; if (!faqContentBo.Insert(connectionHandler, faqContent)) { throw new Exception("خطایی در ذخیره محتوای FAQ وجود دارد"); } } else if (!faqContentBo.Update(connectionHandler, faqContent)) { throw new Exception("خطایی در ویرایش محتوای FAQ وجود دارد"); } return(true); }