Esempio n. 1
0
        public ActionResult Delete(DeleteButtonRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

            if (request == null)
            {
                request = new DeleteButtonRequest();
            }

            using (var factory = new ChannelFactory <IRightsButtonService>("*"))
            {
                var client = factory.CreateChannel();
                var rs     = client.DeleteButton(request);
                if (rs.ReturnCode == ReturnCodeType.Success && rs.Content == true)
                {
                    flag = true;
                    msg  = "删除成功!";
                }
                else
                {
                    msg = rs.Message.IsNullOrEmpty() ? "删除失败!" : rs.Message;
                }
            }

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        /// <summary>
        /// 删除按钮
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool DeleteButton(DeleteButtonRequest request)
        {
            //删除按钮数据
            //删除菜单按钮数据
            //删除角色菜单按钮数据
            //使用事务
            var result   = false;
            var buttonId = request.DeleteButtonId.ToInt();

            using (var conn = DapperHelper.CreateConnection())
            {
                var trans = conn.BeginTransaction();
                try
                {
                    //删除按钮数据
                    conn.Execute(@"DELETE FROM dbo.t_rights_button WHERE id= @ButtonId;", new { @ButtonId = buttonId }, trans);

                    //删除菜单按钮数据
                    conn.Execute(@"DELETE FROM dbo.t_rights_menu_button WHERE button_id= @ButtonId;", new { @ButtonId = buttonId }, trans);

                    //删除角色菜单按钮数据
                    conn.Execute(@"DELETE FROM dbo.t_rights_role_menu_button WHERE button_id= @ButtonId;", new { @ButtonId = buttonId }, trans);

                    trans.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 删除按钮
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ServiceResult <bool> DeleteButton(DeleteButtonRequest request)
        {
            //删除按钮数据
            //删除菜单按钮数据
            //删除角色菜单按钮数据
            //使用事务
            var result = new ServiceResult <bool>
            {
                ReturnCode = ReturnCodeType.Error
            };

            var rs = _btnDao.DeleteButton(request);

            if (rs == true)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
            }

            return(result);
        }
Esempio n. 4
0
        public ActionResult Delete(DeleteButtonRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

            if (request == null)
            {
                request = new DeleteButtonRequest();
            }

            var rs = _buttonService.DeleteButton(request);

            if (rs.ReturnCode == ReturnCodeType.Success && rs.Content == true)
            {
                flag = true;
                msg  = "删除成功!";
            }
            else
            {
                msg = rs.Message.IsNullOrEmpty() ? "删除失败!" : rs.Message;
            }

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }