Exemple #1
0
        //Adds a new podcast
        private async void BtnNewPod_Click(object sender, EventArgs e)
        {
            PodcastFeed.Rows.Clear();
            if (validator.TboxUrlNotEmpty(TxtURL) && validator.PodcastIsUnique(TxtURL.Text) && validator.ComboIntervalChoosen(CmbUpdateFreq) && validator.ComboCategoryChoosen(CmbCat))
            {
                string category = CmbCat.SelectedItem.ToString();
                double interval = IntervalToDouble(CmbUpdateFreq);

                XmlReader       reader = XmlReader.Create(TxtURL.Text);
                SyndicationFeed feed   = SyndicationFeed.Load(reader);

                int numberOfEpisodes = 0;

                List <Episode> episodeList = new List <Episode>();
                string         podcastName = feed.Title.Text;

                foreach (SyndicationItem item in feed.Items)
                {
                    numberOfEpisodes++;
                }
                foreach (SyndicationItem item in feed.Items)
                {
                    string  episodeName = item.Title.Text;
                    string  description = item.Summary.Text;
                    Episode anEpisode   = new Episode(episodeName, description);
                    episodeList.Add(anEpisode);
                }
                await Task.Run(() =>
                {
                    podcastController.CreatePodcastObject(TxtURL.Text, interval, category, podcastName, numberOfEpisodes, episodeList);
                    SetTimer(interval);
                });

                ClearAndSet();
                FormHandler.HideNewPodcastName(TxtNewPodName, BtnNewPodName);
            }
            else
            {
                ClearAndSet();
            }
        }
Exemple #2
0
        private async void NewPodcastBtn_Click(object sender, EventArgs e)
        {
            try
            {
                InsertCommandConsole("Adding item...");
                validator.ComboBoxHasSelected(comboBoxCategory);
                validator.ComboBoxHasSelected(comboBoxInterval);
                validator.TextBoxisNullorEmpty(textBoxNamn);
                validator.TextBoxisNullorEmpty(textBoxURL);
                validator.URLIsValid(textBoxURL.Text);

                int    interval = Int32.Parse(comboBoxInterval.SelectedItem.ToString());
                string category = comboBoxCategory.SelectedItem.ToString();
                string name     = textBoxNamn.Text;
                string URL      = textBoxURL.Text;

                await podcastController.CreatePodcastObject(URL, name, interval, category);

                podcastController.SavePodcastData();
                ClearTimer();
                CreateTimerData();
                InsertPodcasts();

                InsertCommandConsole("Item added.");
            }
            catch (InvalidTextException textError)
            {
                CreateInformationMessage(textError.ErrorMessage());
            }
            catch (InvalidURLException URLError)
            {
                CreateInformationMessage(URLError.ErrorMessage());
            }
            catch (InvalidComboBoxException comboBoxError)
            {
                CreateInformationMessage(comboBoxError.ErrorMessage());
            }
        }