Ejemplo n.º 1
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                SlideBO     slideBo         = new SlideBO();
                Slide       obj             = slideBo.Get(ConnectionHandler, keys);
                SlideItemBO slideItemFacade = new SlideItemBO();

                List <SlideItem> list = new SlideItemBO().Where(ConnectionHandler,
                                                                supporter => supporter.SlideId == obj.Id);
                foreach (SlideItem slideItem in list)
                {
                    if (
                        !slideItemFacade.Delete(ConnectionHandler, FileManagerConnection, slideItem.Id))
                    {
                        throw new Exception("خطایی در ");
                    }
                }

                if (!slideBo.Delete(ConnectionHandler, keys))
                {
                    throw new Exception("خطایی در حذف اسلاید وجود دارد");
                }

                ConnectionHandler.CommitTransaction();
                FileManagerConnection.CommitTransaction();
                return(true);
            }

            catch (KnownException ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }