示例#1
0
        public async Task <BaseResult <bool> > Add(ButtonActionEntity buttonActionEntity)
        {
            buttonActionEntity.action_newaction = buttonActionEntity.action_type == (int)ActionType.adminleft ? true : false;
            var isTrue = await buttonActionRepository.AddAsync(buttonActionEntity);

            if (!isTrue)
            {
                return(new BaseResult <bool>(201, false));
            }
            return(new BaseResult <bool>(200, true));
        }
示例#2
0
        public async Task <BaseResult <bool> > Update(ButtonActionEntity buttonActionEntity)
        {
            //在修改之前判断是否有同名的数据,如果有,则不允许修改
            var isTrue = await buttonActionRepository.UpdateAsync(buttonActionEntity, true, true, c => c.action_name, c => c.action_url,
                                                                  c => c.action_parentid, c => c.action_icon, c => c.action_sort, c => c.action_event, c => c.action_type);

            if (!isTrue)
            {
                return(new BaseResult <bool>(201, false));
            }
            return(new BaseResult <bool>(200, true));
        }
示例#3
0
        public async Task <BaseResult <bool> > NewWorn(string id, int type)
        {
            ButtonActionEntity buttonActionEntity = new ButtonActionEntity()
            {
                action_id        = id,
                action_newaction = type == 1 ? true : false
            };
            var isTrue = await buttonActionRepository.UpdateAsync(buttonActionEntity, true, true, c => c.action_newaction);

            if (!isTrue)
            {
                return(new BaseResult <bool>(201, false));
            }
            return(new BaseResult <bool>(200, true));
        }
示例#4
0
        public async Task <BaseResult <bool> > Disable(string action_id, string disable_desc, int type)
        {
            if (string.IsNullOrEmpty(action_id))
            {
                return(new BaseResult <bool>(800));
            }

            // 禁用之前,判断是否跟角色用户关联(角色权限表和用户临时权限中,如果存在,提示不允许禁用即可)
            int roleButtonActionDataCount = await roleButtonActionRepository.CountAsync(c => c.action_id.Equals(action_id));

            if (roleButtonActionDataCount > 0)
            {
                return(new BaseResult <bool>(901));
            }
            int userButtonActionCount = await userButtonAvtionRepository.CountAsync(c => c.action_id.Equals(action_id));

            if (userButtonActionCount > 0)
            {
                return(new BaseResult <bool>(901));
            }

            //首先查询数据读取原始的desc
            var str = "";
            ButtonActionEntity buttonActionEntity = await buttonActionRepository.GetAsync(b => b.action_id.Equals(action_id));

            if (string.IsNullOrEmpty(buttonActionEntity.disabledesc))
            {
                str = "{'disable':'" + buttonActionEntity.disable + "','disable_desc':'" + disable_desc + "'}";
            }
            else
            {
                str = buttonActionEntity.disabledesc + ",{'disable':'" + buttonActionEntity.disable + "','disable_desc':'" + disable_desc + "'}";
            }
            ButtonActionEntity buttonAction = new ButtonActionEntity()
            {
                action_id   = action_id,
                disabledesc = str,
                disable     = type
            };

            var isTrue = await buttonActionRepository.UpdateAsync(buttonAction, true, true, b => b.disable, b => b.disabledesc);

            if (!isTrue)
            {
                return(new BaseResult <bool>(201, false));
            }
            return(new BaseResult <bool>(200, true));
        }
        public async Task <IActionResult> Add(ButtonActionEntity buttonActionEntity)
        {
            var data = await buttonActionService.Add(buttonActionEntity);

            return(Json(data));
        }