public async Task ReplaceClaimAsync(ApplicationUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var updateUserClaimDto = new UpdateUserClaimDto
            {
                OldClaimType  = claim.Type,
                OldClaimValue = claim.Value,
                NewClaimType  = newClaim.Type,
                NewClaimValue = newClaim.Value,
                UserId        = user.Id
            };

            await _userClaimRepository.Update(updateUserClaimDto);
        }
Exemple #2
0
        public async Task <int> Update(UpdateUserClaimDto updateUserClaimDto)
        {
            const string query = @"
                UPDATE [UserClaims]
                SET 
                    [ClaimType] = @NewClaimType,
                    [ClaimValue] = @NewClaimValue
                WHERE
                    [UserId] = @UserId
                AND [ClaimType] = @OldClaimType
                AND [ClaimValue] = @OldClaimValue
            ";

            using (var connection = _dbConnectionFactory.GetDbConnection())
            {
                var updatedRowsNum = await connection.ExecuteAsync(query, updateUserClaimDto);

                return(updatedRowsNum);
            }
        }
 public async Task <IActionResult> Update([FromRoute] int id, [FromBody] UpdateUserClaimDto updateUserClaimDto)
 {
     return(GetResponseOnlyResultMessage(await Mediator.Send(new  UpdateUserClaimCommand {
         Id = id, UserId = updateUserClaimDto.UserId, ClaimId = updateUserClaimDto.ClaimIds
     })));
 }