public static Settings.V1._ApiKey GetCharacterKey(Settings a_Settings, UInt32 a_CharacterID) { Settings.V1._ApiChar character = a_Settings.ApiAccess.Chars.FirstOrDefault(a => a.CharacterID == a_CharacterID); if (null == character) { return(null); } Settings.V1._ApiKey key = a_Settings.ApiAccess.Keys.FirstOrDefault(a => a.KeyID == character.KeyID); return(key); }
private bool SavePage_ApiKeys() { if (HasOrphanedUsers()) { if (DialogResult.Yes != MessageBox.Show("You entered some users, but did not [Load characters]. If you continue now, the corresponding characters will not be available.\nContinue anyway?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)) { return(false); } } m_Settings.ApiAccess.Keys.Clear(); for (int i = 0; i < LstUsers.Items.Count; i++) { ListViewItem currItem = LstUsers.Items[i]; string userID = currItem.Text; string apiKey = currItem.SubItems[1].Text; Settings.V1._ApiKey newRow = new Settings.V1._ApiKey(); newRow.KeyID = Convert.ToUInt32(userID); newRow.Verification = apiKey; m_Settings.ApiAccess.Keys.Add(newRow); } m_Settings.ApiAccess.Chars.Clear(); for (int i = 0; i < LstCharacters.Items.Count; i++) { ListViewItem currItem = LstCharacters.Items[i]; string keyID = currItem.Text; string charID = currItem.SubItems[1].Text; string charName = currItem.SubItems[2].Text; string charCorp = currItem.SubItems[3].Text; Settings.V1._ApiChar newRow = new Settings.V1._ApiChar(); newRow.KeyID = Convert.ToUInt32(keyID); newRow.CharacterID = Convert.ToUInt32(charID); newRow.CharacterName = charName; newRow.CorporationName = charCorp; m_Settings.ApiAccess.Chars.Add(newRow); } return(true); }
private bool IsCharacterOrphaned(Settings.V1._ApiChar a_Character) { return(!m_Settings.ApiAccess.Keys.Exists(a => (a.KeyID == a_Character.KeyID))); }