Example #1
0
        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool DeleteMenu(DeleteMenuRequest request)
        {
            //删除菜单数据
            //删除菜单按钮数据
            //删除角色菜单按钮数据
            //使用事务
            var result         = false;
            var deletedMenuIds = request.DeleteMenuIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.ToInt()).ToList();

            using (var conn = DapperHelper.CreateConnection())
            {
                var trans = conn.BeginTransaction();
                try
                {
                    //删除菜单数据
                    conn.Execute(@"DELETE FROM dbo.t_rights_menu WHERE id IN @MenuIds;", new { @MenuIds = deletedMenuIds }, trans);

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

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

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

            return(result);
        }
 public SuccessResponse Delete(DeleteMenuRequest request)
 {
     try
     {
         var menu = _menuRepository.FindBy(request.Id);
         menu.ThrowExceptionIfRecordIsNull();
         _menuRepository.Remove(menu);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
Example #3
0
        public ActionResult Delete(DeleteMenuRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

            var rs = _menuService.DeleteMenu(request);

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

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ServiceResult <bool> DeleteMenu(DeleteMenuRequest request)
        {
            //删除菜单数据
            //删除菜单-按钮数据
            //删除角色菜单按钮数据
            //使用事务
            var result = new ServiceResult <bool>
            {
                ReturnCode = ReturnCodeType.Error
            };

            var rs = _menuDao.DeleteMenu(request);

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

            return(result);
        }
Example #5
0
        public ActionResult Delete(DeleteMenuRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

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

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        /// <summary>
        /// 删除菜单测试
        /// </summary>
        public static void DeleteMenuTest()
        {
            IMpClient             mpClient = new MpClient();
            AccessTokenGetRequest request  = new AccessTokenGetRequest()
            {
                AppIdInfo = new AppIdInfo()
                {
                    AppID = appId, AppSecret = appSecret
                }
            };
            AccessTokenGetResponse response = mpClient.Execute(request);

            if (response.IsError)
            {
                Console.WriteLine("获取令牌环失败..");
                return;
            }

            DeleteMenuRequest getRequest = new DeleteMenuRequest()
            {
                AccessToken = response.AccessToken.AccessToken
            };

            var delResponse = mpClient.Execute(getRequest);

            if (delResponse.IsError)
            {
                Console.WriteLine("删除菜单失败,错误信息为:" + delResponse.ErrInfo.ErrCode + "-" + delResponse.ErrInfo.ErrMsg);
            }
            else
            {
                Console.WriteLine("删除菜单成功");

                GetMenuTest(); //成功后查询一下
            }
        }
Example #7
0
 public SuccessResponse Delete(DeleteMenuRequest request)
 {
     return(_menuService.Delete(request));
 }
 public async Task <ActionResult> Delete([FromBody] DeleteMenuRequest command)
 {
     return(await base.Command <DeleteMenuRequest, ICollection <MenuDto> >(command));
 }