コード例 #1
0
        public async Task <ActionResult <IdentityResource> > Save([FromBody] IdentityResource model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ValidationProblemDetails(ModelState)));
            }

            await _identityResourceRepository.InsertAsync(model, true);

            var idr = await _identityResourceRepository.GetAsync(model.Id, true);

            return(CreatedAtAction(nameof(Details), new { resource = model.Name }, idr));
        }
コード例 #2
0
    protected virtual async Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource)
    {
        if (await IdentityResourceRepository.CheckNameExistAsync(resource.Name))
        {
            return;
        }

        await IdentityResourceRepository.InsertAsync(
            new IdentityResource(
                GuidGenerator.Create(),
                resource
                )
            );
    }