public virtual async Task <int> DeleteClientClaimAsync(ClientClaim clientClaim) { var claimToDelete = await DbContext.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync(); DbContext.ClientClaims.Remove(claimToDelete); return(await AutoSaveChangesAsync()); }
public async Task <IActionResult> AddClientClaim([FromRoute] string clientId, [FromBody] CreateClaimRequest request) { var client = await _configurationDbContext.Clients.SingleOrDefaultAsync(x => x.ClientId == clientId); if (client == null) { return(NotFound()); } var claimToAdd = new Entities.ClientClaim { Client = client, ClientId = client.Id, Type = request.Type, Value = request.Value }; client.Claims = new List <Entities.ClientClaim> { claimToAdd }; await _configurationDbContext.SaveChangesAsync(); return(Created(string.Empty, new ClaimInfo { Id = claimToAdd.Id, Type = claimToAdd.Type, Value = claimToAdd.Value })); }
public virtual async Task <int> AddClientClaimAsync(int clientId, ClientClaim clientClaim) { var client = await DbContext.Clients.Where(x => x.Id == clientId).SingleOrDefaultAsync(); clientClaim.Client = client; await DbContext.ClientClaims.AddAsync(clientClaim); return(await AutoSaveChangesAsync()); }