Ejemplo n.º 1
0
        /// <summary>
        /// 刪除角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string DeleteRole(string id)
        {
            string result = string.Empty;

            SQLConnTran sqlConnTran = _sqlConnectionHelper.BeginTransaction();

            int deleteRoleUserResult = _roleUserRepo.DeleteRoleUserByRoleID(id, ref sqlConnTran.SqlConn, ref sqlConnTran.SqlTrans);

            int deleteRoleFunctionResult = _roleFunctionRepo.DeleteRoleFunctionByRoleID(id, ref sqlConnTran.SqlConn, ref sqlConnTran.SqlTrans);

            int deleteRoleResult = _roleRepo.DeleteRole(id, ref sqlConnTran.SqlConn, ref sqlConnTran.SqlTrans);

            if (deleteRoleUserResult >= 0 && deleteRoleFunctionResult >= 0 && deleteRoleResult > 0)
            {
                result = "";
            }
            else
            {
                result = "刪除失敗。";
            }

            _sqlConnectionHelper.Commit(); // tran.Commit();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刪除功能
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string DeleteFunction(string id)
        {
            string result = string.Empty;

            var sqlConnTrans = _sqlConnectionHelper.BeginTransaction();

            int deleteRoleFunctionResult = _roleFunctionRepo.DeleteRoleFunctionByFunctionID(id, ref sqlConnTrans.SqlConn, ref sqlConnTrans.SqlTrans);

            int deleteFunctionResult = _functionRepo.DeleteFunction(id, ref sqlConnTrans.SqlConn, ref sqlConnTrans.SqlTrans);

            if (deleteRoleFunctionResult >= 0 && deleteFunctionResult > 0)
            {
                result = "";
            }
            else
            {
                result = "刪除失敗。";
            }

            _sqlConnectionHelper.Commit();

            return(result);
        }