public bool Insert(Guid congressId, Gallery.DataStructure.Gallery gallery, HttpPostedFileBase fileBase, List <HttpPostedFileBase> httpPostedFileBases) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.GalleryConnection.StartTransaction(IsolationLevel.ReadUncommitted); gallery.IsExternal = true; if ( !GalleryComponent.Instance.GalleryTransactinalFacade(this.GalleryConnection) .Insert(gallery, fileBase, httpPostedFileBases)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } var congessGallery = new CongessGallery { GalleryId = gallery.Id, CongressId = congressId }; if (!new CongessGalleryBO().Insert(this.ConnectionHandler, congessGallery)) { throw new Exception(Resources.Congress.ErrorInSaveCongressGallery); } this.ConnectionHandler.CommitTransaction(); this.GalleryConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.GalleryConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.GalleryConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool Insert(Guid websiteId, Gallery.DataStructure.Gallery gallery, HttpPostedFileBase image) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.GalleryConnection.StartTransaction(IsolationLevel.ReadUncommitted); gallery.IsExternal = true; gallery.CreateDate = Utility.DateTimeUtil.ShamsiDate(DateTime.Now); if (!GalleryComponent.Instance.GalleryTransactinalFacade(this.GalleryConnection).Insert(gallery, image)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } var congessGallery = new DataStructure.Gallery { GalleryId = gallery.Id, WebId = websiteId }; if (!new GalleryBO().Insert(this.ConnectionHandler, congessGallery)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.GalleryConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.GalleryConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.GalleryConnection.RollBack(); throw new KnownException(ex.Message, ex); } }