Exemple #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);
     }
 }
Exemple #2
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);
     }
 }