// Updates the data of a specific podcast private void btnUpdatePod_Click(object sender, EventArgs e) { try { string title = lvPods.SelectedItems[0].SubItems[1].Text; string url = tbUrl.Text; string category = cbCategory.Text; var stringFrequency = cbFrequency.SelectedItem; if (Validator.StringNotEmpty(title) && Validator.StringNotEmpty(category) && Validator.ParseFrequency(stringFrequency)) { int frequency = Int32.Parse(stringFrequency.ToString()); PodcastList.DeletePod(title); EpisodeList.DeleteEpisodes(title); DataLayerAccessor.AddPodcast(url, category, frequency); DataLayerAccessor.CreateFiles(); UpdatePodListView(); lvEpisodes.Items.Clear(); tbEpDescription.Clear(); MessageBox.Show("Podcasten uppdaterades!", "Wohoo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Ingen podcast är vald.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Button to add a new Podcast private void btnAdd_Click(object sender, EventArgs e) { string url = tbUrl.Text; string category = cbCategory.Text; var stringFrequency = cbFrequency.SelectedItem; if (Validator.StringNotEmpty(category) && Validator.ParseFrequency(stringFrequency) && Validator.PodcastAlreadyExist(url)) { int frequency = Int32.Parse(stringFrequency.ToString()); DataLayerAccessor.AddPodcast(url, category, frequency); DataLayerAccessor.CreateFiles(); UpdatePodListView(); } }
// Button to delete a podcast private void btnDeletePod_Click(object sender, EventArgs e) { try { string title = lvPods.SelectedItems[0].SubItems[1].Text; if (Validator.StringNotEmpty(title)) { PodcastList.DeletePod(title); EpisodeList.DeleteEpisodes(title); DataLayerAccessor.CreateFiles(); UpdatePodListView(); lvEpisodes.Items.Clear(); tbEpDescription.Clear(); } } catch { MessageBox.Show("Ingen podcast är vald.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }