예제 #1
0
        public async Task <ClientClaimDto> AddClientClaims(ClientClaimCreateDto clientClaimCreateDto)
        {
            var clientId     = clientClaimCreateDto.ClientId;
            var clientEntity = await _clientRepository.GetByClientIdAsync(clientId);

            if (clientEntity == null)
            {
                return(null);
            }

            var entityModel = clientEntity.ToModel();

            foreach (var claim in clientClaimCreateDto.Claims)
            {
                entityModel.Claims.Add(new System.Security.Claims.Claim(claim.Type, claim.Value));
            }

            var updateEntity = entityModel.ToEntity();

            clientEntity.Claims = updateEntity.Claims;

            await _clientRepository.UpdateAsync(clientEntity);

            return(new ClientClaimDto
            {
                ClientId = clientClaimCreateDto.ClientId,
                Claims = clientClaimCreateDto.Claims
            });
        }
예제 #2
0
        public async Task <IActionResult> CreateClientClaims([FromBody] ClientClaimCreateDto clientClaimCreateDto)
        {
            var result = await _clientClaimService.AddClientClaims(clientClaimCreateDto);

            return(Ok(result));
        }