Beispiel #1
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         var obj         = new GalleryBO().Get(this.ConnectionHandler, keys);
         var photos      = new PhotoBO().Where(this.ConnectionHandler, photo => photo.GalleryId == obj.Id);
         var photoFacade = new PhotoFacade(this.ConnectionHandler);
         foreach (var pic in photos)
         {
             if (!photoFacade.Delete(pic.Id))
             {
                 throw new Exception("خطایی در حذف عکس وجود دارد");
             }
         }
         if (!new GalleryBO().Delete(this.ConnectionHandler, keys))
         {
             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);
     }
 }
Beispiel #2
0
 public bool AddPicsToGallery(Guid galleryId, List <HttpPostedFileBase> newgalleryPics)
 {
     try
     {
         var gallery     = new GalleryBO().Get(this.ConnectionHandler, galleryId);
         var photoFacade = new PhotoFacade(this.ConnectionHandler);
         foreach (var pic in newgalleryPics)
         {
             var photo = new Photo();
             photo.Title      = "Image-" + (newgalleryPics.IndexOf(pic) + 1);
             photo.UploadDate = gallery.CreateDate;
             photo.Uploader   = gallery.Creator;
             photo.GalleryId  = gallery.Id;
             if (!photoFacade.Insert(photo, pic))
             {
                 throw new Exception("خطایی در ذخیره عکس وجود دارد");
             }
         }
         return(true);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Beispiel #3
0
 public bool Delete(List <Photo> deletedImages)
 {
     try
     {
         var photoFacade = new PhotoFacade(this.ConnectionHandler);
         foreach (var deletedImage in deletedImages)
         {
             if (!photoFacade.Delete(deletedImage.Id))
             {
                 throw new Exception("خطایی در خذف عکس وجود دارد");
             }
         }
         return(true);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }