Ejemplo n.º 1
0
        public async Task <ActionResult> AddRolePermission([FromBody] RolePermissionRequest rolePermissionRequest)
        {
            try
            {
                _response = await _rolePermissionService.AddRolePermission(rolePermissionRequest);

                return(new OkObjectResult(_response));
            }
            catch (Exception ex)
            {
                _response.Message = ex.Message;
                _response.Status  = false;
                return(BadRequest(""));
            }
        }
Ejemplo n.º 2
0
        // [AppAuthorize(PermissionTypes.Any, PermissionRule.update_news)]
        public IActionResult AddRolePermission([FromBody] RolePermissionViewModel userRole)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(new GenericResult(false, allErrors)));
            }
            else
            {
                try
                {
                    _rolePermissionService.AddRolePermission(userRole);

                    return(new OkObjectResult(new GenericResult(true, "Add success!!!")));
                }
                catch (Exception ex)
                {
                    return(new OkObjectResult(new GenericResult(false, ex.Message)));
                }
            }
        }