Exemple #1
0
        public async Task <IActionResult> Post(UpdateRolePermissionModel model)
        {
            var role = await RoleSvc.GetByNameAsync(model.Name);

            if (role != null)
            {
                if (role.Id != model.Id)
                {
                    return(new JsonResult(new APIResult <int> {
                        ErrorMsg = "该角色已存在"
                    })
                    {
                        StatusCode = 400
                    });
                }
            }
            UpdateRolePermissionDTO dto = new UpdateRolePermissionDTO();

            dto.Description = model.Description;
            dto.Id          = model.Id;
            dto.Name        = model.Name;
            await RoleSvc.UpdateAsync(dto);

            return(Ok());
        }
Exemple #2
0
        public async Task <IActionResult> Put(AddRolePermissionModel model)
        {
            if (await RoleSvc.GetByNameAsync(model.Name) != null)
            {
                return(new JsonResult(new APIResult <int> {
                    ErrorMsg = "该权限已存在"
                })
                {
                    StatusCode = 400
                });
            }
            AddRolePermissionDTO dto = new AddRolePermissionDTO();

            dto.Name        = model.Name;
            dto.Description = model.Description;
            return(new JsonResult(new APIResult <long> {
                Data = await RoleSvc.AddNewAsync(dto)
            }));
        }