Example #1
0
        public async Task AddClaimAsync(ApplicationRole role, Claim claim, CancellationToken cancellationToken = new CancellationToken())
        {
            cancellationToken.ThrowIfCancellationRequested();

            var createRoleClaimDto = new CreateRoleClaimDto
            {
                ClaimType  = claim.Type,
                ClaimValue = claim.Value,
                RoleId     = role.Id
            };

            await _roleClaimRepository.Create(createRoleClaimDto);
        }
Example #2
0
        public async Task <RoleClaimDto> Create(CreateRoleClaimDto createRoleClaimDto)
        {
            const string query = @"
                INSERT INTO [RoleClaims] ([ClaimType], [ClaimValue], [RoleId])
                VALUES (@ClaimType, @ClaimValue, @RoleId);

                SELECT SCOPE_IDENTITY();
            ";

            using (var connection = _dbConnectionFactory.GetDbConnection())
            {
                var insertedId = await connection.QuerySingleAsync <int>(query, createRoleClaimDto);

                if (insertedId == 0)
                {
                    return(null);
                }

                var roleClaimDto = _mapper.Map <RoleClaimDto>(createRoleClaimDto);
                roleClaimDto.Id = insertedId;

                return(roleClaimDto);
            }
        }