public void LikeMedia(Media media) { if (Likes.Contains(media)) { media.AddLike(false); } else { media.AddLike(true); } }
public void LikeMedia(Media media) { if (Likes.Contains(media)) { media.AddLike(false); Likes.Remove(media); if (media.GetType() == typeof(Song)) { Song s = (Song)media; FavoriteMusic.Remove(s); } else if (media.GetType() == typeof(Video)) { Video v = (Video)media; FavoriteVideos.Remove(v); } } else { media.AddLike(true); Likes.Add(media); if (media.GetType() == typeof(Song)) { Song s = (Song)media; FavoriteMusic.Add(s); } else if (media.GetType() == typeof(Video)) { Video v = (Video)media; FavoriteVideos.Add(v); } } HashSet <Song> songs = new HashSet <Song>(FavoriteMusic); FavoriteMusic = songs.ToList(); HashSet <Video> videos = new HashSet <Video>(FavoriteVideos); FavoriteVideos = videos.ToList(); }