public void AddNewProgramme(ProgrammeJson programme)
        {
            var request = new RestRequest("api/programme", Method.POST);

            request.AddJsonBody(programme);
            request.AddHeader("Content-Type", "application/json");
            var response = this.restClient.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new InvalidOperationException(response.Content);
            }
        }
        private void AddProgrammeBtnClick(object sender, RoutedEventArgs e)
        {
            // Zintegrować do jakiegoś serwisu wraz z identyczną metodą w klasie MainWindow
            var dialog = new AddProgrammeDialog();

            if (dialog.ShowDialog() == true)
            {
                ProgrammeJson programme = dialog.Programme;
                try
                {
                    this.programmeService.AddNewProgramme(programme);
                    MessageBox.Show("Zapis zrealizowany pomyślnie!");
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show("Błąd: " + ex.Message);
                }
            }
        }
 private void InitBinding()
 {
     this.Programme = new ProgrammeJson();
     this.mainContainer.DataContext = this.Programme;
 }
Пример #4
0
        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);
     }
 }