private void listBoxAthletes_DoubleClick(object sender, EventArgs e) { PersonWrapper p = this.listBoxAthletes.SelectedItem as PersonWrapper; API_Models.PersonDetail person = this.apiClient.GetPerson(p.person.Min); this.model.Person = person; if (model.Person.Licenses == null) { MessageBox.Show("No licenses."); return; } API_Models.License license = person.Licenses.FirstOrDefault(l => l.Type == "Athlete"); if (license == null) { return; } this.textBoxAthleteMin.Text = person.Min.ToString(); this.comboBoxAthleteDivision.SelectedIndex = this.comboBoxCoupleDivision.Items.IndexOf(license.Division); this.comboBoxAthleteStatus.SelectedIndex = this.comboBoxAthleteStatus.Items.IndexOf(license.Status); this.labelAthleteWrlBlocked.Text = license.WrlBlockedUntil; this.labelAthleteChBlocked.Text = license.CupOrChampionshipBlockedUntil; if (string.IsNullOrEmpty(license.ExpiresOn)) { this.dateTimePickerAthleteRetireOn.Value = new DateTime(1800, 1, 1); } else { this.dateTimePickerAthleteRetireOn.Value = DateTime.Parse(license.ExpiresOn); } }
private void buttonUpdatePerson_Click(object sender, EventArgs e) { API_Models.PersonDetail person = this.model.Person; if (person == null) { return; } API_Models.License license = person.Licenses.First(l => l.Type == "Athlete"); if (license == null) { return; } license.Division = (string)this.comboBoxAthleteDivision.SelectedItem; license.Status = (string)this.comboBoxAthleteStatus.SelectedItem; if (this.dateTimePickerAthleteRetireOn.Value.Year != 1800) { license.ExpiresOn = this.dateTimePickerAthleteRetireOn.Value.ToString("yyyy-MM-dd"); } try { if (!this.apiClient.UpdatePerson(person)) { MessageBox.Show(this.apiClient.LastApiMessage); } else { MessageBox.Show("License updated"); } } catch (Api.Client.Exceptions.ApiException ex) { MessageBox.Show(ex.InnerException.Message); } listBoxAthletes_DoubleClick(null, null); }