Exemplo n.º 1
0
        public async Task <ActionResult> RegisterApiResouce(ApiResourceViewModel resourceViewModel)
        {
            ActionResult Result = Ok();

            IdentityServer4.Models.ApiResource Resource = new ApiResource
                                                              (resourceViewModel.Name, resourceViewModel.DisplayName);
            if (!string.IsNullOrEmpty(resourceViewModel.Claim))
            {
                Resource.UserClaims = new[] { resourceViewModel.Claim };
            }
            Resource.Scopes = resourceViewModel.Scopes;
            bool IsSuccess = await Repository.AddApiResource(Resource);

            if (!IsSuccess)
            {
                Result = Problem("Error to add ApiResource", null, 500, "", null);
            }
            return(Result);
        }