Exemple #1
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         var obj = new TeacherBO().Get(this.ConnectionHandler, keys);
         var workShopTeacherBO = new WorkShopTeacherBO();
         var byFilter          = workShopTeacherBO.Where(ConnectionHandler, teacher => teacher.TeacherId == obj.Id);
         if (
             byFilter.Any(
                 workShopTeacher =>
                 !workShopTeacherBO.Delete(this.ConnectionHandler, workShopTeacher.WorkShopId,
                                           workShopTeacher.TeacherId)))
         {
             throw new Exception(Resources.Congress.ErrorInDeleteWorkShopTeacher);
         }
         if (!new TeacherBO().Delete(this.ConnectionHandler, keys))
         {
             throw new Exception(Resources.Congress.ErrorInSaveTeacher);
         }
         if (
             !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection)
             .Delete(obj.Id))
         {
             return(false);
         }
         if (obj.ResumeAttachId.HasValue)
         {
             if (
                 !FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection)
                 .Delete((Guid)obj.ResumeAttachId))
             {
                 throw new Exception(Resources.Congress.ErrorInDeleteResume);
             }
         }
         this.ConnectionHandler.CommitTransaction();
         this.EnterpriseNodeConnection.CommitTransaction();
         this.FileManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         this.EnterpriseNodeConnection.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.EnterpriseNodeConnection.RollBack();
         this.FileManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                var fileTransactionalFacade =
                    FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection);
                var obj = new WorkShopBO().Get(this.ConnectionHandler, keys);
                var workShopTeacherBO = new WorkShopTeacherBO();
                var list = workShopTeacherBO.Where(this.ConnectionHandler,
                                                   teacher => teacher.WorkShopId == obj.Id);
                if (list.Any(guid => !workShopTeacherBO.Delete(this.ConnectionHandler, guid.WorkShopId, guid.TeacherId)))
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteWorkShopTeacher);
                }
                if (!new WorkShopBO().Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteWorkShop);
                }
                if (obj.ProgramAttachId != null)
                {
                    if (!fileTransactionalFacade.Delete(obj.ProgramAttachId))
                    {
                        throw new Exception(Resources.Congress.ErrorInDeleteWorkShopprogramFile);
                    }
                }
                if (obj.FileAttachId != null)
                {
                    if (!fileTransactionalFacade.Delete(obj.FileAttachId))
                    {
                        throw new Exception(Resources.Congress.ErrorInEditWorkShopAttachFile);
                    }
                }

                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 RemoveTeacher(IConnectionHandler handler, Guid workShopId, Guid teacherId)
        {
            var workShopTeacherBO = new WorkShopTeacherBO();
            var workShopTeacher   = workShopTeacherBO.Get(handler, workShopId, teacherId);

            if (workShopTeacher == null)
            {
                return(true);
            }
            if (!workShopTeacherBO.Delete(handler, workShopId, teacherId))
            {
                throw new Exception(Resources.Congress.ErrorInDeleteWorkShopTeacher);
            }
            return(true);
        }