/// <summary>
        /// Finds a client by id (and runs the validation logic)
        /// </summary>
        /// <param name="clientId">The client id</param>
        /// <returns>
        /// The client or an InvalidOperationException
        /// </returns>
        public async Task <Client> FindClientByIdAsync(string clientId)
        {
            var client = await _inner.FindClientByIdAsync(clientId);

            if (client != null)
            {
                _logger.LogTrace("Calling into client configuration validator: {validatorType}", _validatorType);

                var context = new ClientConfigurationValidationContext(client);
                await _validator.ValidateAsync(context);

                if (context.IsValid)
                {
                    _logger.LogDebug("client configuration validation for client {clientId} succeeded.", client.ClientId);
                    return(client);
                }
                else
                {
                    _logger.LogError("Invalid client configuration for client {clientId}: {errorMessage}", client.ClientId, context.ErrorMessage);
                    await _events.RaiseAsync(new InvalidClientConfigurationEvent(client, context.ErrorMessage));

                    return(null);
                }
            }

            return(null);
        }
        public async Task <IViewComponentResult> InvokeAsync(string id)
        {
            string clientId = id;

            if (string.IsNullOrWhiteSpace(clientId))
            {
                var clients = await _clientStore.GetAllClientIdsAsync();

                clientId = clients.FirstOrDefault();
            }
            var client = await _clientStore.FindClientByIdAsync(clientId);

            return(View(client as ClientExtra));
        }
        public async Task <IViewComponentResult> InvokeAsync(string id)
        {
            string clientId = id;

            if (string.IsNullOrWhiteSpace(clientId))
            {
                var clients = await _clientStore.GetAllClientIdsAsync();

                clientId = clients.FirstOrDefault();
            }
            var client = await _clientStore.FindClientByIdAsync(clientId);

            var clientRequestIdentity = new ClientRequestIdentity()
            {
                ClientId = clientId
            };

            var rateLimitClientsRule = _processor.GetRateLimitClientsRule(clientRequestIdentity);
            List <RateLimitRuleRecord> rateLimitRuleRecords = new List <RateLimitRuleRecord>();

            if (rateLimitClientsRule != null)
            {
                foreach (var rateLimitRule in rateLimitClientsRule.Settings.RateLimitRules)
                {
                    var rateLimitCounter = _processor.GetStoredRateLimitCounter(clientRequestIdentity, rateLimitRule);
                    rateLimitRuleRecords.Add(new RateLimitRuleRecord()
                    {
                        RateLimitCounter = rateLimitCounter,
                        RateLimitRule    = rateLimitRule
                    });
                }
            }

            var usageRecords = await _clientUsageStore.GetClientUsageRecordsAsync(clientId, null, (null, null));

            var model = new ClientViewComponentModel
            {
                ClientExtra          = client as ClientExtra,
                RateLimitRuleRecords = rateLimitRuleRecords,
                UsageRecords         = usageRecords == null?null:usageRecords.ToList()
            };

            return(View(model));
        }
        public async Task <IViewComponentResult> InvokeAsync(string id)
        {
            var client = await _clientStore.FindClientByIdAsync(id);

            return(View(client as ClientExtra));
        }