Beispiel #1
0
        internal static bool UpdateCategory(string oldCategory, string newCategory)
        {
            bool isCategoryUpdated = false;

            if ((Validater.NotEmpty(oldCategory)) && (Validater.NotEmpty(newCategory)))
            {
                if (!(oldCategory == newCategory))
                {
                    if (Validater.CheckIfCategoryUsed(oldCategory))
                    {
                        Dialog.CategoryUsed();
                    }
                    else
                    {
                        var updateCat = listOfCategory.FirstOrDefault((nv) => nv.Title == oldCategory);
                        updateCat.Title = newCategory;
                        Dialog.CategoryUpdated();
                        isCategoryUpdated = true;
                        new FileHandler().SaveCategories(listOfCategory);
                    }
                }
                else
                {
                    Dialog.NoChange();
                }
            }
            else
            {
                new Dialog().EmptyInput();
            }
            return(isCategoryUpdated);
        }
Beispiel #2
0
        public static bool AddPodcast
            (string nPodcastURL, string nPodcastTitle, string nPodcastInterval, string nPodcastCategory)
        {
            bool podcastAdded = false;

            if ((Validater.NotEmpty(nPodcastURL)) && (Validater.NotEmpty(nPodcastTitle)) && (Validater.NotEmpty(nPodcastInterval)) && (Validater.NotEmpty(nPodcastCategory)))
            {
                if ((Validater.IsURL(nPodcastURL)))
                {
                    if (Validater.CheckPodcastExist(listOfPodcast, nPodcastURL, nPodcastTitle))
                    {
                        Dialog.PodcastExist();
                    }
                    else
                    {
                        int     nPodcastIntervalInt = int.Parse(nPodcastInterval);
                        Podcast createPodcast       = new Podcast(nPodcastURL, nPodcastTitle, nPodcastIntervalInt, nPodcastCategory);
                        listOfPodcast.Add(createPodcast);
                        podcastAdded = true;
                        new FileHandler().SavePodcasts(listOfPodcast);
                    }
                }
                else
                {
                    Dialog.NotURL();
                }
            }
            else
            {
                new Dialog().EmptyInput();
            }
            return(podcastAdded);
        }
Beispiel #3
0
        internal static bool RemoveCategory(string categoryRemove)
        {
            bool catDeleted = false;

            if (Validater.NotEmpty(categoryRemove))
            {
                foreach (var c in listOfCategory)
                {
                    if (c.Title == categoryRemove)
                    {
                        if (Validater.CheckIfCategoryUsed(categoryRemove))
                        {
                            Dialog.CategoryUsed();
                        }
                        else
                        {
                            listOfCategory.Remove(c);
                            catDeleted = true;
                            //Dialog.CategoryRemoved();
                            break;
                        }
                    }
                }
                new FileHandler().SaveCategories(listOfCategory);
            }
            return(catDeleted);
        }
Beispiel #4
0
        internal static bool RemovePodcast(string podcastRemove)
        {
            bool postcastRemoved = false;

            if (Validater.NotEmpty(podcastRemove))
            {
                foreach (var c in listOfPodcast)
                {
                    if (c.Title == podcastRemove)
                    {
                        listOfPodcast.Remove(c);
                        postcastRemoved = true;
                        new FileHandler().SavePodcasts(listOfPodcast);
                        break;
                    }
                }
            }
            return(postcastRemoved);
        }
Beispiel #5
0
        internal static bool UpdatePodcast(Podcast oldPodcast, Podcast newPodcast)
        {
            bool isPodcastUpdate = false;

            if (Validater.CheckIfPodcastChanged(oldPodcast, newPodcast))
            {
                bool updatePodcast = true;
                foreach (var p in listOfPodcast)
                {
                    if ((p.Title == newPodcast.Title) && !(oldPodcast.Title == newPodcast.Title))
                    {
                        Dialog.PodcastExist();
                        updatePodcast = false;
                        break;
                    }
                }
                if (updatePodcast)
                {
                    if (Validater.NotEmpty(newPodcast))
                    {
                        if ((Validater.IsURL(newPodcast.URL)))
                        {
                            ListHandler.RemovePodcast(oldPodcast.Title);
                            listOfPodcast.Add(newPodcast);
                            new FileHandler().SavePodcasts(listOfPodcast);
                            isPodcastUpdate = true;
                            Dialog.PodcastUpdated();
                        }
                        else
                        {
                            Dialog.NotURL();
                        }
                    }
                    else
                    {
                        new Dialog().EmptyInput();
                    }
                }
            }
            return(isPodcastUpdate);
        }
Beispiel #6
0
 public static void AddCategory(string newCategory)
 {
     if (Validater.NotEmpty(newCategory))
     {
         if (Validater.CheckCategoryExist(listOfCategory, newCategory))
         {
             Dialog.CatogeryExist();
         }
         else
         {
             Category createCat = new Category(newCategory);
             listOfCategory.Add(createCat);
             Dialog.CategoryAdded();
             new FileHandler().SaveCategories(listOfCategory);
         }
     }
     else
     {
         new Dialog().EmptyInput();
     }
 }