public void CreateScheduleAndProgramme(ScheduledProgrammeJson schedule, ProgrammeJson programme) { string programmeID = this.programmeService.CreateProgrammeAndReturnId(programme); CreateSchedule(schedule, programmeID); }
private void SaveButtonClick(object sender, RoutedEventArgs e) { try { ScheduledProgrammeJson scheduledProgramme = new ScheduledProgrammeJson(); if (IsWeekDayChecked()) { scheduledProgramme.Day = new DayWrapper() { WeekDay = this.weekDayPickerContainer.WeekDayCB.SelectedIndex + 1 }; } else if (IsDateDayChecked()) { scheduledProgramme.Day = new DayWrapper() { Date = ((DateTime)(this.dateDayPickerContainer.Date.SelectedDate)).ToString("dd-MM-yyyy") }; } else { throw new InvalidOperationException(); } scheduledProgramme.BeginTime = new Time() { Hours = ((DateTime)this.TimeContainer.Value).Hour, Minutes = ((DateTime)this.TimeContainer.Value).Minute }; if (this.CreateNewProgrammeContainer.IsChecked == true) { ProgrammeJson newProgramme = new ProgrammeJson() { Title = this.addProgrammeContainer.newProgrammeTitleTB.Text, Description = this.addProgrammeContainer.newProgrammeDescriptionTB.Text }; try { this.scheduleService.CreateScheduleAndProgramme(scheduledProgramme, newProgramme); MessageBox.Show("Zapis zrealizowany pomyślnie!"); DialogResult = true; } catch (InvalidOperationException ex) { MessageBox.Show("Błąd: " + ex.Message); } } else if (this.CreateNewProgrammeContainer.IsChecked == false) { var selectedProgramme = (ExistingProgrammeJson)this.chooseProgrammeContainer.ChooseProgrammeCB.SelectedItem; var programmeID = selectedProgramme.Id; try { this.scheduleService.CreateSchedule(scheduledProgramme, programmeID); MessageBox.Show("Zapis zrealizowany pomyślnie!"); DialogResult = true; } catch (InvalidOperationException ex) { MessageBox.Show("Błąd: " + ex.Message); } } else { throw new InvalidOperationException(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }