public async Task <Result <bool> > AddUserClaim(UserClaimModel userClaimModel, string scope, string description)
        {
            // check to see if the desired scope exists
            var dalUserClaims = await _userClaimRepository.GetAllUserClaimsByUserAccountId(userClaimModel.UserAccountId);

            var claimMatch = (dalUserClaims.Where(x => x.Type == userClaimModel.Type).FirstOrDefault());

            if (claimMatch != null)
            {
                return(Result <bool> .Failure(ErrorMessage.UserAlreadyContainsClaim));
            }

            var dalScopes  = (await _scopeRepository.GetAllScopes()).ToList();
            var scopeMatch = dalScopes.Where(x => x.Type == scope).FirstOrDefault();
            int scopeId    = -1;

            if (scopeMatch == null)
            {
                scopeId = await _scopeRepository.CreateScope(new ScopeModel()
                {
                    Type        = scope,
                    Description = description,
                    IsDefault   = false
                });
            }
            else
            {
                scopeId = scopeMatch.Id;
            }

            var claimId = await _userClaimRepository.CreateUserClaim(ModelConverterService.ConvertTo(userClaimModel, new DALUserClaimModel()));

            await _scopeClaimRepository.CreateScopeClaim(new ScopeClaimModel()
            {
                ScopeId = scopeId,
                ClaimId = claimId
            });

            return(Result <bool> .Success(true));
        }
        public async Task <int> CreateScope(ScopeModel scopeModel)
        {
            try
            {
                var dataScope = ModelConverterService.ConvertTo(scopeModel, new Models.User_Access_Control.ScopeModel());
                var scopeId   = await _scopeRepository.CreateScope(dataScope);

                foreach (var claim in scopeModel.Claims)
                {
                    await _scopeClaimRepository.CreateScopeClaim(new Models.User_Access_Control.ScopeClaimModel()
                    {
                        ScopeId = scopeId,
                        ClaimId = claim.Id
                    });
                }

                return(scopeId);
            }
            catch (SqlCustomException e)
            {
                throw new SqlCustomException(e.InnerException.Message, e.InnerException);
            }
        }