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); }