public bool Insert(DataStructure.Gallery obj, HttpPostedFileBase image) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); if (image != null) { obj.Thumbnail = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection).Insert(image); } if (!new GalleryBO().Insert(this.ConnectionHandler, obj)) { 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(DataStructure.Gallery obj, HttpPostedFileBase image, List <HttpPostedFileBase> data) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection); if (image != null) { if (obj.Thumbnail.HasValue) { fileTransactionalFacade.Update(image, (Guid)obj.Thumbnail); } else { obj.Thumbnail = fileTransactionalFacade.Insert(image); } } if (data != null) { foreach (var httpPostedFileBase in data) { var photo = new Photo { GalleryId = obj.Id, Title = httpPostedFileBase.FileName, PicFile = fileTransactionalFacade.Insert(httpPostedFileBase) }; if (!new PhotoBO().Insert(this.ConnectionHandler, photo)) { throw new Exception("خطایی در ذخیره گالری وجود دارد"); } } } if (!new GalleryBO().Update(this.ConnectionHandler, obj)) { 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 Insert(DataStructure.Gallery obj, List <HttpPostedFileBase> galleryPics) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); if (!new GalleryBO().Insert(this.ConnectionHandler, obj)) { throw new Exception("خطایی در ذخیره گالری وجود دارد"); } foreach (var pic in galleryPics) { var photo = new Photo(); photo.Title = "Image-" + (galleryPics.IndexOf(pic) + 1); photo.UploadDate = obj.CreateDate; photo.Uploader = obj.Creator; photo.GalleryId = obj.Id; if (!new PhotoFacade(this.ConnectionHandler).Insert(photo, pic)) { throw new Exception("خطایی در ذخیره عکس وجود دارد"); } } this.ConnectionHandler.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public static bool HasImage(this DataStructure.Gallery gallery) { return(new GalleryFacade().HasPhoto(gallery.Id)); }
public static bool HasChild(this DataStructure.Gallery gallery) { return(new GalleryFacade().HasChild(gallery.Id)); }