示例#1
0
        //The methods are orderd from top to bottom first are all the events and methods regarding to Podcasts and then Categories
        private async void btnNewPodcast_Click_1Async(object sender, EventArgs e)
        {
            try
            {
                var podname    = Interaction.InputBox("Namnge podcasten: ", "Spara", "NyPodcast").CheckIfCancel();
                var podCastDTO = new PodCastDTO {
                    Url        = txtUrl.Text.CheckIfURL().CheckIfSameUrl(),
                    Interval   = double.Parse(cmbBoxInterval.Text.CheckIfEmpty()),
                    CategoryId = _categoryController.GetCategory(cmbBoxCategory.Text.CheckIfEmpty()),
                    Name       = podname.CheckIfEmpty().CheckIfSame()
                };
                await _podcastController.CreatePodcastAsync(podCastDTO);

                ShowPodCastSubscriptions();
            }

            catch (EmptyValueException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
            catch (NotAValidURLException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
            catch (CancelOrEmtpyException)
            {}
            catch (SameValueException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
            catch (SameUrlValueException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
        }
示例#2
0
        private async void btnUpdatePodCast_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                lstVPodcast.SelectedItems.Count.CheckIfIndexExist();
                string podname    = Interaction.InputBox("Namnge podcasten: ", "Spara", lstVPodcast.SelectedItems[0].SubItems[1].Text.CheckIfObjectIsEmpty().ToString()).CheckIfCancel();
                var    podCastDTO = new PodCastDTO
                {
                    Url        = txtUrl.Text.CheckIfURL(),
                    Interval   = double.Parse(cmbBoxInterval.Text.CheckIfEmpty()),
                    CategoryId = _categoryController.GetCategory(cmbBoxCategory.Text.CheckIfEmpty()),
                    Name       = podname.CheckIfEmpty().CheckIfSame(podname)
                };
                var selectedPod = lstVPodcast.FocusedItem.SubItems[1].Text;
                var podId       = _podcastController.GetPodCast(selectedPod).Id;
                await _podcastController.UpdatePodcastAsync(podId, podCastDTO);

                FillCategoryComboBox();
                ShowPodCastSubscriptions();
            }
            catch (EmptyValueException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
            catch (NotAValidURLException err)
            {
                MessageBox.Show(err.ErrorMessage());
            }
            catch (CancelOrEmtpyException) {}
            catch (SameValueException) {}
            catch (NoIndexException) {}
        }
        public async Task UpdatePodcastAsync(Guid id, PodCastDTO payLoad)
        {
            try
            {
                var pod = await _rssFeed.GetFeedAsync(payLoad.Url);

                var episodes = pod.Episodes;
                pod.Episodes       = null;
                pod.Id             = id;
                pod.Url            = payLoad.Url;
                pod.CategoryId     = payLoad.CategoryId;
                pod.Name           = payLoad.Name;
                pod.UpdateInterval = payLoad.Interval;
                pod.NextUpdate     = DateTime.Now.AddMinutes(payLoad.Interval);
                _episodeRepository.UpdateEpisodes(id, episodes);
                _podcastRepository.Update(id, pod);
            }
            catch (Exception) {}
        }
        public async Task CreatePodcastAsync(PodCastDTO payLoad)
        {
            try
            {
                var pod = await _rssFeed.GetFeedAsync(payLoad.Url).CheckIfObjectIsEmpty();

                var episodes = pod.Episodes;
                pod.Id             = Guid.NewGuid();
                pod.Episodes       = null;
                pod.Url            = payLoad.Url;
                pod.CategoryId     = payLoad.CategoryId;
                pod.Name           = payLoad.Name;
                pod.UpdateInterval = payLoad.Interval;
                pod.NextUpdate     = DateTime.Now.AddMinutes(payLoad.Interval);
                foreach (var episode in episodes)
                {
                    episode.PodcastID = pod.Id;
                }

                _episodeRepository.Create(episodes, pod.Id);
                _podcastRepository.Create(pod);
            }
            catch (Exception) {}
        }