public ActionResult AddNewCloneChart(string ChartGuid, string ChartName, string ChartDesc, string ChartDate, int UserID, string existingChartGuid) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.chartsManager chartManager = new hypster_tv_DAL.chartsManager(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); if (chartManager.GetChartByGuid(ChartGuid).Chart_ID == 0) { //create cloned chart hypster_tv_DAL.Chart newClonedChart = new hypster_tv_DAL.Chart(); newClonedChart.Chart_GUID = ChartGuid; newClonedChart.Chart_Name = ChartName; newClonedChart.Chart_Desc = ChartDesc; newClonedChart.Chart_Date = ChartDate; newClonedChart.Chart_User_ID = UserID; //get existing chart hypster_tv_DAL.Chart existing_chart = new hypster_tv_DAL.Chart(); existing_chart = chartManager.GetChartByGuid(existingChartGuid); //get existing songs for cloning List <hypster_tv_DAL.PlaylistData_Song> existing_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); existing_songs = playlistManager.GetSongsForPlayList((int)existing_chart.Chart_User_ID, (int)existing_chart.Chart_Playlist_ID); //clone playlist hypster_tv_DAL.Playlist existing_playlist = new hypster_tv_DAL.Playlist(); existing_playlist = playlistManager.GetUserPlaylistById((int)existing_chart.Chart_User_ID, (int)existing_chart.Chart_Playlist_ID); hypster_tv_DAL.Playlist new_playlist = new hypster_tv_DAL.Playlist(); new_playlist.create_time = 0; new_playlist.is_artist_playlist = false; new_playlist.name = existing_playlist.name + " CLONE"; new_playlist.update_time = 0; new_playlist.userid = existing_playlist.userid; new_playlist.ViewsNum = 0; new_playlist.Likes = 0; int new_playlist_id = playlistManager.AddNewPlaylist(new_playlist); //assign to chart new cloned playlist newClonedChart.Chart_Playlist_ID = new_playlist_id; //clone songs List <hypster_tv_DAL.PlaylistData_Song> new_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); foreach (var item in existing_songs) { hypster_tv_DAL.PlaylistData song = new hypster_tv_DAL.PlaylistData(); song.playlist_id = new_playlist_id; song.userid = new_playlist.userid; song.sortid = item.sortid; song.songid = (int)item.id; hypDB.PlaylistDatas.AddObject(song); hypDB.SaveChanges(); } //add new cloned chart (after playlist cloned) chartManager.AddNewChart(newClonedChart); } return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult SaveHypsterChart(List <int> playlist_songs_list, string conv_PlaylistName, int conv_UserID) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.Playlist add_playlist = new hypster_tv_DAL.Playlist(); add_playlist.name = conv_PlaylistName; add_playlist.userid = conv_UserID; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); add_playlist.create_time = crtd_i; int new_plst_id = playlistManager.AddNewPlaylist(add_playlist); short Sel_Sort_Order = 1; if (playlist_songs_list != null) { foreach (int item_id in playlist_songs_list) { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = new_plst_id; new_playlistData.songid = item_id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = conv_UserID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); Sel_Sort_Order++; } } return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult ConvertYearToPlaylist(string plst_name, int?curr_year, int?user_id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { List <hypster_tv_DAL.PlaylistData_Song> new_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); short CURR_SORT_ID = 1; int CURR_USER_ID = (int)user_id; //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.Playlist new_playlist = new hypster_tv_DAL.Playlist(); new_playlist.create_time = 0; new_playlist.is_artist_playlist = false; new_playlist.name = plst_name; new_playlist.update_time = 0; new_playlist.userid = (int)user_id; new_playlist.ViewsNum = 0; new_playlist.Likes = 0; int NEW_PLAYLIST_ID = playlistManager.AddNewPlaylist(new_playlist); //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- string currURL = "http://en.wikipedia.org/wiki/Billboard_Year-End_Hot_100_singles_of_" + curr_year.ToString(); var strContent = ""; var webRequest = WebRequest.Create(currURL); using (var response = webRequest.GetResponse()) using (var content = response.GetResponseStream()) using (var reader = new StreamReader(content)) { strContent = reader.ReadToEnd(); } //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(strContent); ViewBag.Chart_Header = "Billboard Year-End Hot 100 singles of " + curr_year; ViewBag.curr_year = curr_year; //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- if (curr_year >= 1982) { HtmlAgilityPack.HtmlNode songNode = doc.DocumentNode.SelectSingleNode("/html/body/div/div/div/table"); if (songNode != null) { HtmlAgilityPack.HtmlNodeCollection nodes_list = doc.DocumentNode.SelectNodes("/html/body/div/div/div/table/tr/td"); if (nodes_list != null) { int i_counter = 1; for (var i = 0; i < nodes_list.Count; i += 2) { if ((i + 1) < nodes_list.Count) { // get curr song guid //----------------------------------------------------------------------------------------- string artist_song = ""; artist_song = nodes_list[i].InnerText + " - " + nodes_list[i + 1].InnerText; Video CURR_VIDEO = new Video(); CURR_VIDEO = GetSongVideoByTitle(artist_song); //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { if (CURR_VIDEO.Title != null && CURR_VIDEO.VideoId != null) { //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = CURR_VIDEO.Title; new_song.YoutubeId = CURR_VIDEO.VideoId; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; if (CURR_VIDEO.Author != null) { new_song.Author = CURR_VIDEO.Uploader; } //if (CURR_VIDEO.RatingAverage != null) if (CURR_VIDEO.RatingAverage != 0) { new_song.Rating = (float)CURR_VIDEO.RatingAverage; } if (CURR_VIDEO.AppControl != null) { new_song.Syndication = 1; } hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- i_counter += 1; CURR_SORT_ID += 1; } } } } } else { HtmlAgilityPack.HtmlNode songNode = doc.DocumentNode.SelectSingleNode("/html/body/div/div/div/table"); if (songNode != null) { HtmlAgilityPack.HtmlNodeCollection nodes_list = doc.DocumentNode.SelectNodes("/html/body/div/div/div/table/tr/td"); if (nodes_list != null) { int i_counter = 1; for (var i = 0; i < nodes_list.Count; i += 3) { if ((i + 2) < nodes_list.Count) { // get curr song guid //----------------------------------------------------------------------------------------- string artist_song = ""; artist_song = nodes_list[i + 1].InnerText + " - " + nodes_list[i + 2].InnerText; Video CURR_VIDEO = new Video(); CURR_VIDEO = GetSongVideoByTitle(artist_song); //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = CURR_VIDEO.Title; new_song.YoutubeId = CURR_VIDEO.VideoId; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; if (CURR_VIDEO.Author != null) { new_song.Author = CURR_VIDEO.Uploader; } if (CURR_VIDEO.RatingAverage != 0) { new_song.Rating = (float)CURR_VIDEO.RatingAverage; } if (CURR_VIDEO.AppControl != null) { new_song.Syndication = 1; } hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- i_counter += 1; CURR_SORT_ID += 1; } } } } } //------------------------------------------------------------------------------------------------------------------------------- return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult SubmitAddNewSongPopup(string Song_Title, string Song_Guid, int?Sel_Playlist_ID, int?StayHereCheck) { // 1.genral declarations //-------------------------------------------------------------------------------------------- hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); //-------------------------------------------------------------------------------------------- //get curr user //----------------------------------------------------------------------------------------- hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member(); curr_user = userManager.getMemberByUserName(User.Identity.Name); //----------------------------------------------------------------------------------------- //check if user has default playlist //----------------------------------------------------------------------------------------- if (curr_user.active_playlist == 0) { hypster_tv_DAL.Playlist create_playlist = new hypster_tv_DAL.Playlist(); create_playlist.name = curr_user.username + "'s playlist"; create_playlist.userid = curr_user.id; if (create_playlist.name.Length > 60) { create_playlist.name = create_playlist.name.Substring(0, 60); } hypDB.Playlists.AddObject(create_playlist); hypDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(curr_user.id); if (playlists_list.Count > 0) { curr_user.active_playlist = playlists_list[0].id; userManager.SetUserDefaultPlaylist(User.Identity.Name, curr_user.id, curr_user.active_playlist); } //else error - need to have dafult playlist } //----------------------------------------------------------------------------------------- //check if user selected playlist //----------------------------------------------------------------------------------------- if (Sel_Playlist_ID == null || Sel_Playlist_ID == 0) { Sel_Playlist_ID = curr_user.active_playlist; } //----------------------------------------------------------------------------------------- // get last sort_number //----------------------------------------------------------------------------------------- short Sel_Sort_Order = 0; //List<hypster_tv_DAL.PlaylistData_Song> songs_list = new List<hypster_tv_DAL.PlaylistData_Song>(); //songs_list = playlistManagement.GetSongsForPlayList(curr_user.id, (int)Sel_Playlist_ID); //if (songs_list.Count > 0) //{ // Sel_Sort_Order = songs_list[0].sortid; // for (int i = 0; i < songs_list.Count; i++) // { // if (songs_list[i].sortid > Sel_Sort_Order) // Sel_Sort_Order = songs_list[i].sortid; // } //} //Sel_Sort_Order += 1; playlistManagement.IncrementPlaylistSongOrder(curr_user.id, (int)Sel_Playlist_ID); //set sort order to first position Sel_Sort_Order = 1; //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(Song_Guid); //----------------------------------------------------------------------------------------- if (Song_Title.Length > 160) { Song_Title = Song_Title.Substring(0, 160); } //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { string video_Author = ""; float video_RatingAverage = 0; byte video_AppControl = 0; string video_Title = ""; try { //need to get song details YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA"); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + Song_Guid; Video video = request.Retrieve <Video>(new Uri(feedUrl)); if (video.Author != null) { video_Author = video.Uploader; } if (video.RatingAverage != null) { video_RatingAverage = (float)video.RatingAverage; } if (video.AppControl != null) { video_AppControl = 1; } if (video.Title != null) { video_Title = video.Title; } } catch (Exception ex) { } //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = video_Title; new_song.YoutubeId = Song_Guid; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; new_song.Author = video_Author; new_song.Rating = video_RatingAverage; new_song.Syndication = video_AppControl; hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(Song_Guid); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Sel_Playlist_ID; new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = userManager.getMemberByUserName(User.Identity.Name).id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Sel_Playlist_ID; new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = curr_user.id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- return(Content("SUCCESS", "text/html")); //----------------------------------------------------------------------------------------- }
public ActionResult clonePlaylist() { hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel model = new hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement(); string playlistId = Request.QueryString["playlistId"]; string playlistName = ""; if (playlistId != "") { hypster_tv_DAL.Member member = new hypster_tv_DAL.Member(); if (Request.QueryString["cloneTo"] != "") { member = memberManager.getMemberByUserName(Request.QueryString["cloneTo"]); } else { member = memberManager.getMemberByUserName(User.Identity.Name); } if (Request.QueryString["playlistName"] != "") { playlistName = Request.QueryString["playlistName"]; hypster_tv_DAL.Playlist playlist = new hypster_tv_DAL.Playlist(); playlist.name = playlistName; playlist.userid = member.id; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); playlist.create_time = crtd_i; if (playlist.name.Length > 60) { playlist.name = playlist.name.Substring(0, 60); } hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.Playlists.AddObject(playlist); hyDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManager.GetUserPlaylists(member.id); int clLsId = playlists_list[playlists_list.Count - 1].id; int plId = Convert.ToInt32(playlistId); model.playlistData_Song = playlistManager.GetPlayListDataByPlaylistID(plId); model.tags_list = tagManager.GetPlaylistTags(plId); for (int i = 0; i < model.playlistData_Song.Count; i++) { if (model.playlistData_Song[i].id != null) { hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = clLsId; new_playlistData.songid = (int)model.playlistData_Song[i].id; new_playlistData.sortid = model.playlistData_Song[i].sortid; new_playlistData.userid = member.id; hyDB.PlaylistDatas.AddObject(new_playlistData); hyDB.SaveChanges(); } } for (int j = 0; j < model.tags_list.Count; j++) { if (model.tags_list[j].Tag_ID != null) { hypster_tv_DAL.Tag_Playlist plTag = new hypster_tv_DAL.Tag_Playlist(); plTag.Playlist_ID = clLsId; plTag.Tag_ID = model.tags_list[j].Tag_ID; hyDB.Tag_Playlist.AddObject(plTag); hyDB.SaveChanges(); } } } else { Exception PlaylistNameNull = new Exception("The Playlist Name is NULL.\n\n"); Response.Write("Error: " + PlaylistNameNull.Message); } } else { Exception PlaylistIdNull = new Exception("The Playlist ID " + playlistId + " is NULL.\n\n"); Response.Write("Error: " + PlaylistIdNull.Message); } return(RedirectPermanent("/Editors/managePlaylist/")); }
public string SubmitAddNewSong(string Song_Title, string Song_Guid, string Sel_Playlist_ID) { hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member(); curr_user = userManager.getMemberByUserName(User.Identity.Name); if (curr_user.active_playlist == 0) { hypster_tv_DAL.Playlist create_playlist = new hypster_tv_DAL.Playlist(); create_playlist.name = curr_user.username + "'s playlist"; create_playlist.userid = curr_user.id; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); create_playlist.create_time = crtd_i; if (create_playlist.name.Length > 60) { create_playlist.name = create_playlist.name.Substring(0, 60); } hypDB.Playlists.AddObject(create_playlist); hypDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(curr_user.id); if (playlists_list.Count > 0) { curr_user.active_playlist = playlists_list[0].id; userManager.SetUserDefaultPlaylist(User.Identity.Name, curr_user.id, curr_user.active_playlist); } //else error - need to have dafult playlist } //----------------------------------------------------------------------------------------- //check if user selected playlist //----------------------------------------------------------------------------------------- if (Sel_Playlist_ID == null) { Sel_Playlist_ID = curr_user.active_playlist.ToString(); } //----------------------------------------------------------------------------------------- // get last sort_number //----------------------------------------------------------------------------------------- short Sel_Sort_Order = 0; playlistManagement.IncrementPlaylistSongOrder(curr_user.id, Convert.ToInt32(Sel_Playlist_ID)); //set sort order to first position Sel_Sort_Order = 1; //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(Song_Guid); //----------------------------------------------------------------------------------------- if (Song_Title.Length > 75) { Song_Title = Song_Title.Substring(0, 75); } //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = System.Configuration.ConfigurationManager.AppSettings["YouTubeAPIKEY"], ApplicationName = System.Configuration.ConfigurationManager.AppSettings["YouTubeAPIKEYName"] }); var searchListRequest = youtubeService.Search.List("id,snippet"); searchListRequest.Q = Song_Guid; // Replace with your search term. searchListRequest.MaxResults = 1; var searchListResponse = searchListRequest.Execute(); SearchResult video = new SearchResult(); foreach (var searchResult in searchListResponse.Items) { switch (searchResult.Id.Kind) { case "youtube#video": video = searchResult; break; } } //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = Song_Title; new_song.YoutubeId = Song_Guid; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; new_song.Author = ""; new_song.Rating = 1; new_song.Syndication = 1; hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(Song_Guid); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Convert.ToInt32(Sel_Playlist_ID); new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = userManager.getMemberByUserName(User.Identity.Name).id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Convert.ToInt32(Sel_Playlist_ID); new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = curr_user.id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } return("A New Song, " + Song_Title + " (ID: " + Song_Guid + ") has been added to the Playlist, " + playlistManagement.GetPlaylistById(Convert.ToInt32(Sel_Playlist_ID))[0].name); //return RedirectPermanent("/Editors/managePlaylist/?playlist_id=" + Sel_Playlist_ID); }