private async void AddSessionButton_Click(object sender, RoutedEventArgs e) { AddSessionButton.IsEnabled = false; try { if (ValidateForm()) { if (await CheckDate() && await CheckChairman() && await CheckRoom()) { if (currentSession == null && currentSpecialSession == null) { if (SpecialSessionCheck.IsChecked.Value) { var specialSession = new SpecialSessionDTO() { Title = TitleBox.Text, BeginDate = BeginDatePicker.SelectedDate.Value, EndDate = EndDatePicker.SelectedDate.Value, ChairId = (await authCore.GetAccountByLoginAsync(ChairmanBox.Text)).AccountId, ConferenceId = UserCredentials.Conference.ConferenceId, Description = DescriptionBox.Text, RoomId = ((RoomDTO)RoomBox.SelectedItem).RoomID }; if (await core.AddSpecialSessionAsync(specialSession)) { MessageBox.Show("Successfully added special session"); Close(); } else { MessageBox.Show("Something went wrong while adding special session"); } } else { var session = new SessionDTO() { Title = TitleBox.Text, BeginDate = BeginDatePicker.SelectedDate.Value, EndDate = EndDatePicker.SelectedDate.Value, ChairId = (await authCore.GetAccountByLoginAsync(ChairmanBox.Text)).AccountId, ConferenceId = UserCredentials.Conference.ConferenceId, Description = DescriptionBox.Text, RoomId = ((RoomDTO)RoomBox.SelectedItem).RoomID }; if (await core.AddSessionAsync(session)) { MessageBox.Show("Successfully added session"); Close(); } else { MessageBox.Show("Something went wrong while adding session"); } } } if (currentSession != null) { currentSession.Title = TitleBox.Text; currentSession.BeginDate = BeginDatePicker.SelectedDate.Value; currentSession.EndDate = EndDatePicker.SelectedDate.Value; currentSession.ChairId = (await authCore.GetAccountByLoginAsync(ChairmanBox.Text)).AccountId; currentSession.ConferenceId = UserCredentials.Conference.ConferenceId; currentSession.Description = DescriptionBox.Text; currentSession.RoomId = ((RoomDTO)RoomBox.SelectedItem).RoomID; if (await core.EditSessionAsync(currentSession)) { MessageBox.Show("Successfully edited session"); Close(); } else { MessageBox.Show("Something went wrong while editing session"); } } if (currentSpecialSession != null) { currentSpecialSession.Title = TitleBox.Text; currentSpecialSession.BeginDate = BeginDatePicker.SelectedDate.Value; currentSpecialSession.EndDate = EndDatePicker.SelectedDate.Value; currentSpecialSession.ChairId = (await authCore.GetAccountByLoginAsync(ChairmanBox.Text)).AccountId; currentSpecialSession.ConferenceId = UserCredentials.Conference.ConferenceId; currentSpecialSession.Description = DescriptionBox.Text; currentSpecialSession.RoomId = ((RoomDTO)RoomBox.SelectedItem).RoomID; if (await core.EditSpecialSessionAsync(currentSpecialSession)) { MessageBox.Show("Successfully edited special session"); Close(); } else { MessageBox.Show("Something went wrong while editing special session"); } } } else { MessageBox.Show("Some data is overlapping with another session/event or login is invalid"); Refresh_Click(null, null); } } else { MessageBox.Show("Form invalid"); } } catch { MessageBox.Show("Something went wrong, try again"); } AddSessionButton.IsEnabled = true; }