public ActionResult GetPlaylistDetails_Check(int id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { int plst_id = id; ViewBag.plst_id = plst_id; hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); List <hypster_tv_DAL.PlaylistData_Song> songs_list = new List <hypster_tv_DAL.PlaylistData_Song>(); songs_list = playlistManager.GetPlayListDataByPlaylistID(plst_id); //get playlist details return(View(songs_list)); } else { return(RedirectPermanent("/home/")); } }
public void ProcessRequest(HttpContext context) { int userId = -1; int playlistId = -1; bool isRandom = false; // old logic has this (do not remove) if (!int.TryParse(context.Request.QueryString["id"], out userId)) // try parse in [user_id]:[playlist_id]:[is_random] format { if (context.Request.QueryString["id"].Contains(":") == false) { return; // exit if : char isnt present } var data = context.Request.QueryString["id"].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (data.Count() != 3) { return; // exit if param count doesn't equal 3 } userId = int.Parse(data[0]); playlistId = int.Parse(data[1]); isRandom = data[2] == "0" ? false : true; } if (!int.TryParse(context.Request.QueryString["us_id"], out userId)) { userId = 0; } //-------------------------------------------------------------------------------------------------------------------- hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); List <hypster_tv_DAL.PlaylistData_Song> playlist_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); hypster_tv_DAL.Member member = new hypster_tv_DAL.Member(); //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- XElement xml; XNamespace jwNS = "http://developer.longtailvideo.com/trac/wiki/FlashFormats"; int i = 1; //need to shuffle if set if ((context.Request.QueryString["shuffle"] != null && context.Request.QueryString["shuffle"].Equals("true", StringComparison.CurrentCultureIgnoreCase)) || isRandom) { if (playlistId == -1) { member = memberManager.getMemberByID(userId); playlist_songs = playlistManagement.GetPlayListDataByPlaylistID_Random(member.active_playlist); } else { playlist_songs = playlistManagement.GetPlayListDataByPlaylistID_Random(playlistId); } } else { if (playlistId == -1) { member = memberManager.getMemberByID(userId); playlist_songs = playlistManagement.GetPlayListDataByPlaylistID(member.active_playlist); } else { playlist_songs = playlistManagement.GetPlayListDataByPlaylistID(playlistId); } } //-------------------------------------------------------------------------------------------------------------------- //prepare playlist songs //-------------------------------------------------------------------------------------------------------------------- ArrayList tracks_list_xml = new ArrayList(); foreach (hypster_tv_DAL.PlaylistData_Song item in playlist_songs) { XElement songs_xml = new XElement("track", new XAttribute("id", item.playlist_track_id), new XElement("youtubeId", item.YoutubeId ?? "null"), new XElement("type", (item.YoutubeId == "") ? "mp3" : "youtube"), new XElement("title", item.FullTitle), new XElement("link", "http://www.hypster.com/song/" + item.playlist_track_id.ToString()), new XElement("location", (item.YoutubeId == "") ? "http://www.hypster.com/Handlers/Stream.ashx?id=" + item.playlist_track_id.ToString() + "&pid=" + playlistId + "&type=.mp3" : "http://www.youtube.com/watch?v=" + item.YoutubeId + "&id=" + item.playlist_track_id.ToString() + "&pid=" + playlistId + "&type=youtube") ); tracks_list_xml.Add(songs_xml); } //-------------------------------------------------------------------------------------------------------------------- //populate playlist //-------------------------------------------------------------------------------------------------------------------- xml = new XElement("playlist", new XAttribute(XNamespace.Xmlns + "jwplayer", jwNS.NamespaceName), new XElement("tracklist", tracks_list_xml), new XElement("data", new XElement("title", " - Hypster Radio"), new XElement("username", "N/A"), new XElement("photo", "N/A"), new XElement("truename", "N/A"), new XElement("gender", "N/A"), new XElement("country", "N/A"), new XElement("city", "N/A"), new XElement("introduce", "N/A"))); //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- context.Response.ContentType = "text/xml"; context.Response.Write(xml.ToString(SaveOptions.DisableFormatting)); //-------------------------------------------------------------------------------------------------------------------- }
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/")); }