public string GetPodcastUrl(int index) { var podcastList = podcastRepository.GetAll(); Podcast podcast = podcastList[index]; string url = podcast.Url; return(url); }
//Updates a category object public void UpdateCategoryObject(int index, string oldCategory, Category updateCategory) { if (updateCategory == null) { updateCategory = new Category(updateCategory.Name); } categoryRepository.Update(index, updateCategory); PodcastRepository podRepo = new PodcastRepository(); var podList = podRepo.GetAll(); //Loops through all saved podcasts foreach (var item in podList) { if (item.Category.Equals(oldCategory)) { //If the objects Category property is the same as the oldCategory parameter the new category is set item.Category = updateCategory.Name; } } podRepo.SaveChanges(podList); }
//Returns true if the parameter is not already in the Podcasts file public bool PodcastIsUnique(string url) { bool isValid = true; try { List <Podcast> list = podRepo.GetAll(); foreach (var item in list) { string link = item.Url; if (link.Equals(url)) { isValid = false; throw new PodcastAlreadyExistsException(); } } } catch (PodcastAlreadyExistsException) { } return(isValid); }
public PodcastController() { podcastRepository = new PodcastRepository(); podcastList = podcastRepository.GetAll(); }
public List <Podcast> RetrieveAllPodcasts() { return(podcastRepository.GetAll()); }