private void Choose(int index) { if (exclusive || !choiceManager.chosenIndices.Contains(index)) { choiceManager.AddChoice(index, exclusive); } else { choiceManager.RemoveChoice(index); } UpdateUI(); }
private async void CreateButton_Click(object sender, RoutedEventArgs e) { var dialog = new Windows.UI.Popups.MessageDialog(""); if (StudentNumberBox.Text != "" || FirstNameBox.Text != "" || LastNameBox.Text != "") { if (Choice1ComboBox.SelectedValue != Choice2ComboBox.SelectedValue || Choice1ComboBox.SelectedValue != Choice3ComboBox.SelectedValue || Choice1ComboBox.SelectedValue != Choice4ComboBox.SelectedValue || Choice2ComboBox.SelectedValue != Choice3ComboBox.SelectedValue || Choice2ComboBox.SelectedValue != Choice4ComboBox.SelectedValue || Choice3ComboBox.SelectedValue != Choice4ComboBox.SelectedValue) { string studentId = StudentNumberBox.Text; string fName = FirstNameBox.Text; string lName = LastNameBox.Text; int firstChoice = (int)Choice1ComboBox.SelectedValue; int secondChoice = (int)Choice2ComboBox.SelectedValue; int thirdChoice = (int)Choice3ComboBox.SelectedValue; int fourthChoice = (int)Choice4ComboBox.SelectedValue; int YearTermId = defaultYearTerm.YearTermId; var obj = new { StudentId = studentId, StudentFirstName = fName, StudentLastName = lName, FirstChoiceOptionId = firstChoice, SecondChoiceOptionId = secondChoice, ThirdChoiceOptionId = thirdChoice, FourthChoiceOptionId = fourthChoice, YearTermId = YearTermId, SelectionDate = DateTime.Now.ToString() }; var obj2 = App.Current as App; ChoiceManager.http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", obj2.AccessToken); await ChoiceManager.AddChoice(new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json")); } else { dialog = new Windows.UI.Popups.MessageDialog("Your choices must be unique."); await dialog.ShowAsync(); } } else { dialog = new Windows.UI.Popups.MessageDialog("Do not leave any of the fields empty."); await dialog.ShowAsync(); } }