// //no additional methods here since it will be traslated into song url /song/GUID // //---------------------------------------------------------------------------------------------------------- // for song landing page //[OutputCache(Duration = 1200, VaryByParam = "none")] public ActionResult getSongByID(string song_guid) { // 1.general declarations //----------------------------------------------------------------------------------------------------- hypster_tv_DAL.songsManagement song_manager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); //----------------------------------------------------------------------------------------------------- int song_int_id = 0; if (Int32.TryParse(song_guid, out song_int_id) == false) { return(RedirectPermanent("/")); } // 2.get model //----------------------------------------------------------------------------------------------------- hypster.ViewModels.SongLandingPageViewModel songModel = new ViewModels.SongLandingPageViewModel(); songModel.song = song_manager.GetSongByID(song_guid); songModel.songComments_list = song_manager.Get_SongComments(songModel.song.id); //----------------------------------------------------------------------------------------------------- return(View(songModel)); }
public ActionResult Radio() { hypster.ViewModels.listenViewModel model = new ViewModels.listenViewModel(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.MemberMusicGenreManager genreManager = new hypster_tv_DAL.MemberMusicGenreManager(); model.genres_list = genreManager.GetMusicGenresList(); hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); model.most_popular_songs = songManager.Get_MostPopularSong_Random(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); if (User.Identity.IsAuthenticated == true) { model.most_viewed_playlists = playlistManager.GetUserPlaylists(memberManager.getMemberByUserName(User.Identity.Name).id); } else { model.most_viewed_playlists = playlistManager.GetMostViewedPlaylists(); } hypster_tv_DAL.visualSearchManager visualSearchManager = new hypster_tv_DAL.visualSearchManager(); model.visualSearch_list = visualSearchManager.getVisualSearchArtists_cached(); //check if search requested if (Request.QueryString["ss"] != null) { ViewBag.searchString = Request.QueryString["ss"]; } return(View(model)); }
public ActionResult MostPopularSongs() { hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); List <hypster_tv_DAL.Song> songs_list = songsManager.Get_MostPopularSong_Random(); return(View(songs_list)); }
public ActionResult Get_MostPopularSong_Random() { hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); List <hypster_tv_DAL.Song> model = songManager.Get_MostPopularSong_Random(); return(View(model)); }
public string SubmitDeadLink(int id) { int song_id = id; hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); songManager.MarkDeadLink(song_id); return(""); }
public ActionResult PopularMusicOnHypster() { hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); List <hypster_tv_DAL.Song> most_popular_songs = new List <hypster_tv_DAL.Song>(); most_popular_songs = songManager.Get_MostPopularSong_Random(); return(View(most_popular_songs)); }
public ActionResult Widget_MostPopularSongs() { hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); List <hypster_tv_DAL.Song> songs_list = songsManager.Get_MostPopularSong_Random(); if (songs_list.Count > 20) { songs_list.RemoveRange(20, songs_list.Count - 20); } return(View(songs_list)); }
public ActionResult Index() { 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.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); model.member = memberManager.getMemberByUserName(User.Identity.Name); model.playlist = playlistManager.GetUserPlaylists(model.member.id); int playlist_id = 0; if (Request.QueryString["playlist_id"] != null) { playlist_id = Convert.ToInt32(Request.QueryString["playlist_id"]); } else { playlist_id = model.member.active_playlist; } foreach (var item in model.playlist) { if (item.id == playlist_id) { ViewBag.ActivePlaylistName = item.name; ViewBag.ActivePlaylistID = item.id; } } if (playlist_id != 0) { model.playlistData_Song = playlistManager.GetSongsForPlayList(model.member.id, playlist_id); } hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement(); if (playlist_id != 0) { model.tags_list = tagManager.GetPlaylistTags(playlist_id); } else { model.tags_list = tagManager.GetPlaylistTags(model.member.active_playlist); } ViewBag.TotalResults = model.playlistData_Song.Count; //ViewBag.PageSize = 20; return(View(model)); }
public ActionResult PostSongComment(string songComment, string songGuid) { if (User.Identity.IsAuthenticated == false) { return(RedirectPermanent("/account/SignIn?ReturnUrl=/song/" + songGuid)); } hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.Song curr_song = new hypster_tv_DAL.Song(); curr_song = songManager.GetSongByID(songGuid); hypster_tv_DAL.songComment p_comment = new hypster_tv_DAL.songComment(); p_comment.song_ID = curr_song.id; p_comment.ipAddress = IpAddress(); p_comment.status = (int)hypster_tv_DAL.newsCommentStatus.NoActive; p_comment.user_ID = memberManager.getMemberByUserName(User.Identity.Name).id; p_comment.userName = User.Identity.Name; p_comment.postDate = DateTime.Now; p_comment.comment = songComment; if (p_comment.comment.Length > 1990) { p_comment.comment = p_comment.comment.Substring(0, 1990); } hyDB.songComments.AddObject(p_comment); hyDB.SaveChanges(); return(RedirectPermanent("/song/" + songGuid)); }
public void ProcessRequest(HttpContext context) { //-------------------------------------------------------------------------------------------------------------------- string id = context.Request.QueryString["id"].ToString(); //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.Song item = new hypster_tv_DAL.Song(); item = songManager.GetSongByGUID(id); //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- XElement xml; XNamespace jwNS = "http://developer.longtailvideo.com/trac/wiki/FlashFormats"; xml = new XElement("playlist", new XAttribute(XNamespace.Xmlns + "jwplayer", jwNS.NamespaceName), new XElement("title", "Hypster Radio"), new XElement("tracklist", new XElement("track", new XAttribute("id", item.id), new XElement("title", HttpUtility.HtmlEncode(item.FullTitle)), new XElement("location", (item.YoutubeId == "") ? "http://www.hypster.com/Handlers/Stream.ashx?id=" + item.id + "&pid=0&type=.mp3" : "http://www.youtube.com/watch?v=" + item.YoutubeId + "&id=" + item.id + "&pid=0&type=youtube") ))); //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- context.Response.ContentType = "text/xml"; context.Response.Write(xml.ToString()); //-------------------------------------------------------------------------------------------------------------------- }
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 playlist() { hypster.ViewModels.createPlaylist_ViewModel model = new ViewModels.createPlaylist_ViewModel(); // 1.general declarations //----------------------------------------------------------------------------------------------------- hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); model.curr_user = memberManager.getMemberByUserName(User.Identity.Name); //----------------------------------------------------------------------------------------------------- // 2.proccess user actions if any //----------------------------------------------------------------------------------------------------- // process user actions if (Request.QueryString["ACT"] != null) { switch (Request.QueryString["ACT"].ToString()) { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ case "delete_playlist": int d_playlist_id = 0; if (Int32.TryParse(Request.QueryString["playlist_id"], out d_playlist_id) == false) { d_playlist_id = 0; } if (d_playlist_id != 0) { playlistManager.Delete_Playlist(model.curr_user.id, d_playlist_id); return(RedirectPermanent("/create/playlist")); } break; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ case "delete_song": int d_song_id = 0; if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id) == false) { d_song_id = 0; } string pl_id = ""; if (Request.QueryString["playlist_id"] != null) { pl_id = Request.QueryString["playlist_id"].ToString(); } if (d_song_id != 0) { playlistManager.DeleteSong(model.curr_user.id, d_song_id); return(RedirectPermanent("/create/playlist?playlist_id=" + pl_id)); } break; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ case "delete_song_plr": int d_song_id1 = 0; if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id1) == false) { d_song_id1 = 0; } if (d_song_id1 != 0) { playlistManager.DeleteSong(model.curr_user.id, d_song_id1); if (Request.QueryString["ret_url"] == null) { return(RedirectPermanent("/create/playlist")); } else { return(RedirectPermanent("/create/playlist")); } } break; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ default: break; } } //----------------------------------------------------------------------------------------------------- // 3.prepare output model //----------------------------------------------------------------------------------------------------- //hypster.ViewModels.AccountPlaylistsViewModel model = new ViewModels.AccountPlaylistsViewModel(); //model.curr_user = member_user; model.userPlaylists_list = playlistManager.GetUserPlaylists(model.curr_user.id); //----------------------------------------------------------------------------------------------------- // 4. get current requested playlist id // if no playlist selected display default //----------------------------------------------------------------------------------------------------- int playlist_id = 0; if (Request.QueryString["playlist_id"] != null) { if (Int32.TryParse(Request.QueryString["playlist_id"], out playlist_id) == false) { playlist_id = 0; } } else { playlist_id = model.curr_user.active_playlist; } //----------------------------------------------------------------------------------------------------- // 5.get selected playlist details //----------------------------------------------------------------------------------------------------- foreach (var item in model.userPlaylists_list) { if (item.id == playlist_id) { ViewBag.ActivePlaylistName = item.name; ViewBag.ActivePlaylistID = item.id; } } //----------------------------------------------------------------------------------------------------- // 6.get songs for selected playlist //----------------------------------------------------------------------------------------------------- if (playlist_id != 0) { model.userActivePlaylist_Songs_list = playlistManager.GetSongsForPlayList(model.curr_user.id, playlist_id); } else { model.userActivePlaylist_Songs_list = playlistManager.GetSongsForPlayList(model.curr_user.id, model.curr_user.active_playlist); } //----------------------------------------------------------------------------------------------------- return(View(model)); }
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 delelePlaylistSong() { 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.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); model.member = memberManager.getMemberByUserName(User.Identity.Name); if (Request.QueryString["ACT"] != null) { switch (Request.QueryString["ACT"].ToString()) { case "delete_playlist": int d_playlist_id = 0; if (Int32.TryParse(Request.QueryString["playlist_id"], out d_playlist_id) == false) { d_playlist_id = 0; } if (d_playlist_id != 0) { playlistManager.Delete_Playlist(model.member.id, d_playlist_id); //check if this playlist is default if (model.member.active_playlist == d_playlist_id) { memberManager.SetUserDefaultPlaylist(User.Identity.Name, model.member.id, 0); } return(RedirectPermanent("/Editors/managePlaylist/")); } break; case "delete_song": int d_song_id = 0; if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id) == false) { d_song_id = 0; } string pl_id = ""; if (Request.QueryString["playlist_id"] != null) { pl_id = Request.QueryString["playlist_id"].ToString(); } if (d_song_id != 0) { playlistManager.DeleteSong(model.member.id, d_song_id); return(RedirectPermanent("/Editors/managePlaylist/?playlist_id=" + pl_id)); } break; case "delete_song_plr": int d_song_id1 = 0; if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id1) == false) { d_song_id1 = 0; } if (d_song_id1 != 0) { playlistManager.DeleteSong(model.member.id, d_song_id1); return(RedirectPermanent("/Editors/managePlaylist/")); } break; default: break; } } model.playlist = playlistManager.GetUserPlaylists(model.member.id); int playlist_id = 0; if (Request.QueryString["playlist_id"] != null) { if (Int32.TryParse(Request.QueryString["playlist_id"], out playlist_id) == false) { playlist_id = 0; } } else { playlist_id = model.member.active_playlist; } foreach (var item in model.playlist) { if (item.id == playlist_id) { ViewBag.ActivePlaylistName = item.name; ViewBag.ActivePlaylistID = item.id; } } if (playlist_id != 0) { model.playlistData_Song = playlistManager.GetSongsForPlayList(model.member.id, playlist_id); } else { model.playlistData_Song = playlistManager.GetSongsForPlayList(model.member.id, model.member.active_playlist); } hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement(); if (playlist_id != 0) { model.tags_list = tagManager.GetPlaylistTags(playlist_id); } else { model.tags_list = tagManager.GetPlaylistTags(model.member.active_playlist); } return(View(model)); }
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); }