public Model.CustomerApiKeyRule GetCustomerApiKeyRuleById(int id)
        {
            CustomerApiKeyRule customerApiKeyRule = _context.CustomerApiKeyRule.SingleOrDefault(x => id.Equals(x.Id));

            Model.CustomerApiKeyRule customerApiKeyRuleModel = customerApiKeyRule?.MapFull();
            return(customerApiKeyRuleModel);
        }
        public void DeleteCustomerApiKeyRule(int id)
        {
            CustomerApiKeyRule customerApiKeyRule = _context.CustomerApiKeyRule.SingleOrDefault(x => x.Id.Equals(id));

            if (customerApiKeyRule == null)
            {
                throw new ArgumentException($"Apikey rule with id: {id} not exists");
            }
            _context.CustomerApiKeyRule.Remove(customerApiKeyRule);
            _context.Save();
        }
        public int AddCustomerApiKeyRule(Model.CustomerApiKeyRule customerApiKeyRuleModel)
        {
            CustomerApiKeyRule customerApiKeyRule = customerApiKeyRuleModel.MapFull();

            if (string.IsNullOrEmpty(customerApiKeyRule.ApplicationName) || customerApiKeyRule.ApplicationName.Contains("*"))
            {
                throw new ArgumentException($"This apikey is public and does not allow System to be wildcard.");
            }

            _context.CustomerApiKeyRule.Add(customerApiKeyRule);
            _context.Save();

            return(customerApiKeyRule.Id);
        }
        public int UpdateCustomerApiKeyRule(Model.CustomerApiKeyRule customerApiKeyRuleModel)
        {
            CustomerApiKeyRule customerApiKeyRule = _context.CustomerApiKeyRule.SingleOrDefault(x => x.Id.Equals(customerApiKeyRuleModel.Id));

            if (customerApiKeyRule == null)
            {
                throw new ArgumentException($"No data found with id: {customerApiKeyRule.Id}");
            }

            customerApiKeyRuleModel.MapFull(customerApiKeyRule);
            if (string.IsNullOrEmpty(customerApiKeyRule.ApplicationName) || customerApiKeyRule.ApplicationName.Contains("*"))
            {
                throw new ArgumentException($"This Apikey is public and does not allow System to be wildcard.");
            }

            _context.Save();
            return(customerApiKeyRule.Id);
        }