Exemple #1
0
 private void ListaKategorier_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (categoryListview.SelectedItems.Count > 0)
     {
         if (categoryListview.SelectedItems[0].Text == "Visa alla podcasts" && podcastListview.Items.Count > 0)
         {
             podcastListview.BeginUpdate();
             podcastListview = PodcastHandler.updatePodcastListview(podcastListview);
             podcastListview.EndUpdate();
             podcastListview.Items[0].Selected = true;
         }
         else if (podcastListview.Items.Count > 0 && PodcastHandler.lookupTrue(categoryListview.SelectedItems[0].Text, "podcast"))
         {
             podcastListview.BeginUpdate();
             podcastListview = PodcastHandler.updatePodcastListview(podcastListview, categoryListview.SelectedItems[0].Text);
             podcastListview.EndUpdate();
             podcastListview.Items[0].Selected = true;
         }
         else if (podcastListview.Items.Count == 0)
         {
             MessageBox.Show("Du har inte lagt till några podcasts än");
         }
         else
         {
             MessageBox.Show("Inga podcasts tillhör kategorin");
         }
     }
 }
Exemple #2
0
    public static bool validateSelectedCategory(string category, string modifier)
    {
        switch (modifier)
        {
        case "remove":
            string podcasts = "";
            if (PodcastHandler.lookupTrue(category, "podcast"))
            {
                foreach (var podcast in PodcastHandler.getPodcasts(category))
                {
                    podcasts = podcast.Title + ", " + podcasts;
                }
                MessageBox.Show("Följande podcasts tillhör " + category + " kategorin: \n" + podcasts + " \n ändra kategori för podcastsen för att ta bort kategorin");
                break;
            }
            MessageBox.Show("Kategori borttagen");
            return(true);

        case "add":
            if (PodcastHandler.lookupTrue(category, "category"))
            {
                MessageBox.Show("Kategorin finns redan i listan");
                break;
            }
            return(true);

        case "edit":
            if (PodcastHandler.lookupTrue(category, "podcast"))
            {
                MessageBox.Show("Podcasts tillhör den valda kategorin, vänligen ändra kategori för dessa podcasts för att ändra");
                break;
            }
            return(true);
        }
        return(false);
    }