public async Task <IActionResult> Edit(int id, [Bind("Id,ApiResourceId,Type")] ApiClaims apiClaims)
        {
            if (id != apiClaims.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apiClaims);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApiClaimsExists(apiClaims.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(apiClaims));
        }
        public async Task <IActionResult> Create([Bind("Id,ApiResourceId,Type")] ApiClaims apiClaims)
        {
            if (ModelState.IsValid)
            {
                _context.Add(apiClaims);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(apiClaims));
        }
        private async Task CleanupApiResourceAsync(ApiResource entity, CancellationToken cancellationToken = default(CancellationToken))
        {
            //Remove old identity claims
            var apiResourceClaims = await ApiClaims.Where(x => x.ApiResource.Id == entity.Id).ToListAsync();

            ApiClaims.RemoveRange(apiResourceClaims);

            //Remove old proprs
            var apiProps = await ApiProperties.Where(x => x.ApiResource.Id == entity.Id).ToListAsync();

            ApiProperties.RemoveRange(apiProps);

            //Remove old scopes
            var apiScopes = await ApiScopes.Where(x => x.ApiResource.Id == entity.Id).ToListAsync();

            ApiScopes.RemoveRange(apiScopes);

            //Remove old secrets
            var apiSecrets = await ApiSecrets.Where(x => x.ApiResource.Id == entity.Id).ToListAsync();

            ApiSecrets.RemoveRange(apiSecrets);
        }
 public static string MapApiClaim(this ApiClaims apiClaims)
 {
     return(apiClaims.Type);
 }