public async Task <bool> Execute(AddClaimParameter request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (string.IsNullOrWhiteSpace(request.Code))
            {
                throw new ArgumentNullException(nameof(request.Code));
            }

            if (request.IsIdentifier)
            {
                throw new IdentityServerManagerException(ErrorCodes.InvalidRequestCode, ErrorDescriptions.CannotInsertClaimIdentifier);
            }

            var claim = await _claimRepository.GetAsync(request.Code);

            if (claim != null)
            {
                throw new IdentityServerManagerException(ErrorCodes.InvalidRequestCode, ErrorDescriptions.ClaimExists);
            }

            return(await _claimRepository.InsertAsync(request));
        }
Example #2
0
        public async Task <Result <int> > Handle(CreateClaimCommand request, CancellationToken cancellationToken)
        {
            var claim = _mapper.Map <Claim>(request);
            await _claimRepository.InsertAsync(claim);

            await _unitOfWork.Commit(cancellationToken);

            return(Result <int> .Success(claim.Id));
        }
        internal override HandleResponse HandleIt(CreateClaimCommand request, CancellationToken cancellationToken)
        {
            var claim = new Domain.Entities.Claim()
            {
                ClaimType  = request.ClaimType,
                ClaimValue = request.ClaimValue,
                Name       = request.Name
            };

            var id = _claimRepository.InsertAsync(claim).Result;

            claim.Id = id;

            return(new HandleResponse()
            {
                Content = claim, ContentIdentification = claim.Id
            });
        }
        public async Task<Claim> Insert([FromBody] Claim claim)
        {
            var result = await _repository.InsertAsync(claim);

            return result;
        }