public Model.CustomerApiKey GetCustomerApiKeyById(int id) { CustomerApiKey customerApiKey = _context.CustomerApiKey.SingleOrDefault(x => id.Equals(x.Id)); Model.CustomerApiKey customerApiKeyModel = customerApiKey?.MapFull(); return(customerApiKeyModel); }
public void DeleteCustomerApiKey(int id) { CustomerApiKey customerApiKey = _context.CustomerApiKey.SingleOrDefault(x => x.Id.Equals(id)); if (customerApiKey == null) { throw new ArgumentException($"Id: {id} not exists"); } _context.CustomerApiKey.Remove(customerApiKey); _context.Save(); }
public int ToggleLock(int id, bool isLocked, string lockedUntil) { CustomerApiKey customerApiKey = _context.CustomerApiKey.SingleOrDefault(x => x.Id.Equals(id)); if (customerApiKey == null) { throw new ArgumentException($"No data found with id: {id}"); } customerApiKey?.MapFull(isLocked, lockedUntil); _context.Save(); return(customerApiKey.Id); }
public int AddCustomerApiKey(Model.CustomerApiKey customerApiKeyModel) { if (string.IsNullOrEmpty(customerApiKeyModel.ApiKey)) { throw new ArgumentException($"Apikey value is null or empty"); } CustomerApiKey customerApiKey = customerApiKeyModel.MapFull(); _context.CustomerApiKey.Add(customerApiKey); _context.Save(); return(customerApiKey.Id); }
public int UpdateCustomerApiKey(Model.CustomerApiKey customerApiKeyModel) { if (customerApiKeyModel.Id == 0) { throw new ArgumentException($"Id is not valid"); } CustomerApiKey customerApiKey = _context.CustomerApiKey.SingleOrDefault(x => x.Id.Equals(customerApiKeyModel.Id)); if (customerApiKey == null) { throw new ArgumentException($"No data found with id: {customerApiKeyModel.Id}"); } customerApiKeyModel.MapFull(customerApiKey); _context.Save(); return(customerApiKey.Id); }