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));
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        //authentitication implemented inside (ajax call)
        public string deletePlaylistSong()
        {
            //--------------------------------------------------------------------------------------------
            if (User.Identity.IsAuthenticated == false)
            {
                return("not authorized");
            }
            //--------------------------------------------------------------------------------------------



            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.memberManagement   memberManager = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement songManager   = new hypster_tv_DAL.playlistManagement();
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            int SONG_ID = 0;

            if (Request.QueryString["SONG_ID"] != null && Int32.TryParse(Request.QueryString["SONG_ID"], out SONG_ID) == true)
            {
                songManager.DeleteSong(memberManager.getMemberByUserName(User.Identity.Name).id, SONG_ID);
                return("true");
            }
            //--------------------------------------------------------------------------------------------



            return("false");
        }
        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/"));
            }
        }
Example #4
0
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        public ActionResult Widget_MostLikedPlaylists()
        {
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();

            List <hypster_tv_DAL.Playlist> playlist_list = new List <hypster_tv_DAL.Playlist>();

            return(View(playlist_list));
        }
        public ActionResult GetMostViewedPlaylists()
        {
            hypster.ViewModels.listenViewModel model = new ViewModels.listenViewModel();

            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            model.most_viewed_playlists = playlistManager.GetMostViewedPlaylists();

            return(View(model));
        }
        public ActionResult PopularPlaylists()
        {
            hypster_tv_DAL.playlistManagement playlistsManager      = new hypster_tv_DAL.playlistManagement();
            List <hypster_tv_DAL.Playlist>    most_viewed_playlists = new List <hypster_tv_DAL.Playlist>();

            most_viewed_playlists = playlistsManager.GetMostViewedPlaylists();


            return(View(most_viewed_playlists));
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        //authentitication implemented inside (ajax call)
        public ActionResult getPlaylistDetailsEdt()
        {
            //--------------------------------------------------------------------------------------------
            if (User.Identity.IsAuthenticated == false)
            {
                return(RedirectPermanent("/account/SignIn"));
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            List <hypster_tv_DAL.PlaylistData_Song> songs_list = new List <hypster_tv_DAL.PlaylistData_Song>();

            int playlist_id = 0;

            if (Request.QueryString["PL_ID"] != null && Int32.TryParse(Request.QueryString["PL_ID"], out playlist_id) == true)
            {
                ViewBag.Playlist = playlist_id;

                hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
                hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();

                hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member();
                curr_user = memberManager.getMemberByUserName(User.Identity.Name);


                List <hypster_tv_DAL.Playlist> playlists_list = new List <hypster_tv_DAL.Playlist>();
                playlists_list = playlistManager.GetUserPlaylists(curr_user.id);


                foreach (var item in playlists_list)
                {
                    if (playlist_id == item.id) //check if playlist belong to user
                    {
                        hypster.ViewModels.getAccountInfo_PublicViewModel model = new ViewModels.getAccountInfo_PublicViewModel();
                        songs_list = playlistManager.GetSongsForPlayList(curr_user.id, playlist_id);
                    }
                }
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            if (Request.QueryString["PL_TYPE"] != null)
            {
                ViewBag.PlayerType = Request.QueryString["PL_TYPE"];
            }
            //--------------------------------------------------------------------------------------------


            return(View(songs_list));
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        //authentitication implemented inside (ajax call)
        public ActionResult getPlaylistDetailsPlayer()
        {
            //--------------------------------------------------------------------------------------------
            // CAN BE ANONYMOUS
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            List <hypster_tv_DAL.PlaylistData_Song> songs_list = new List <hypster_tv_DAL.PlaylistData_Song>();

            int user_id = 0;

            if (Request.QueryString["US_ID"] != null)
            {
                Int32.TryParse(Request.QueryString["US_ID"], out user_id);
            }
            else
            {
                hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
                hypster_tv_DAL.Member           curr_user     = new hypster_tv_DAL.Member();
                curr_user = memberManager.getMemberByUserName(User.Identity.Name);
                user_id   = curr_user.id;
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            int playlist_id = 0;

            if (Request.QueryString["PL_ID"] != null && Int32.TryParse(Request.QueryString["PL_ID"], out playlist_id) == true)
            {
                hypster_tv_DAL.playlistManagement playlistManager       = new hypster_tv_DAL.playlistManagement();
                hypster.ViewModels.getAccountInfo_PublicViewModel model = new ViewModels.getAccountInfo_PublicViewModel();


                if (Request.QueryString["Sort"] != null && Request.QueryString["Sort"] != "")
                {
                    songs_list = playlistManager.GetSongsForPlayList_Random(user_id, playlist_id);
                }
                else
                {
                    songs_list = playlistManager.GetSongsForPlayList(user_id, playlist_id);
                }
            }
            //--------------------------------------------------------------------------------------------



            return(View(songs_list));
        }
Example #9
0
 public ActionResult Generate_Hypster_WithDesc_Playlists()
 {
     if (Session["Roles"] != null && Session["Roles"].Equals("Admin"))
     {
         hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
         List <hypster_tv_DAL.Playlist>    model           = new List <hypster_tv_DAL.Playlist>();
         model = playlistManager.GetWithDescPlaylists();
         return(View(model));
     }
     else
     {
         return(RedirectPermanent("/home/"));
     }
 }
Example #10
0
        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));
        }
Example #11
0
        public ActionResult addNewSongs()
        {
            hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel model = new ViewModels.PlaylistViewModel();

            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();

            if (User.Identity.IsAuthenticated == true)
            {
                model.playlist = playlistManager.GetUserPlaylists(memberManager.getMemberByUserName(User.Identity.Name).id);
            }
            ViewBag.playlist_id = Request.QueryString["playlist"].ToString();

            return(View(model));
        }
Example #12
0
 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 ActionResult Edit(string plst_desc, int plst_id)
 {
     if (Session["Roles"] != null && Session["Roles"].Equals("Admin"))
     {
         hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
         if (plst_desc.Length < 100)
         {
             int length = 100 - plst_desc.Length;
             plst_desc = plst_desc.PadRight(100, ' ');
         }
         playlistManager.UpdatePlaylistDesc(plst_id, plst_desc);
         return(RedirectPermanent("/WebsiteManagement/hypPublicPlaylists"));
     }
     else
     {
         return(RedirectPermanent("/home"));
     }
 }
Example #14
0
 public ActionResult DetectDeadLinks_List(string id)
 {
     if (Session["Roles"] != null && Session["Roles"].Equals("Admin"))
     {
         string user_name = id;
         hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
         hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
         hypster_tv_DAL.Member             curr_user       = new hypster_tv_DAL.Member();
         curr_user = memberManager.getMemberByUserName(user_name);
         List <hypster_tv_DAL.Playlist> playlists_list = new List <hypster_tv_DAL.Playlist>();
         playlists_list = playlistManager.GetUserPlaylists(curr_user.id);
         return(View(playlists_list));
     }
     else
     {
         return(RedirectPermanent("/home/"));
     }
 }
Example #15
0
        public ActionResult New_Player_For_Tumblr_Code_2()
        {
            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.playerManagement   playerManager   = new hypster_tv_DAL.playerManagement();
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            hypster.ViewModels.GetPlayerViewModel model = new ViewModels.GetPlayerViewModel();
            model.curr_user      = memberManager.getMemberByUserName(User.Identity.Name);
            model.playlists_list = playlistManager.GetUserPlaylists(model.curr_user.id);
            //--------------------------------------------------------------------------------------------


            return(View(model));
        }
Example #16
0
        public string DeleteDealLink(int id)
        {
            int song_id = id;

            hypster_tv_DAL.memberManagement member_manager = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.Member           curr_member    = new hypster_tv_DAL.Member();
            string user_name = "";

            if (Request.QueryString["user_name"] != null)
            {
                user_name   = Request.QueryString["user_name"].ToString();
                curr_member = member_manager.getMemberByUserName(user_name);
            }
            else
            {
                return("wrong/missing user_name");
            }
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            playlistManager.DeleteSong(curr_member.id, song_id);
            return("ok");
        }
        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/"));
            }
        }
Example #18
0
        //--------------------------------------------------------------------------------------------------------
        public string addnewtag()
        {
            string ret_res  = "";
            string tag_name = "";

            if (Request.QueryString["tag_name"] != null)
            {
                tag_name = Request.QueryString["tag_name"].ToString();
            }

            int playlist_id = 0;

            if (Request.QueryString["playlist_id"] != null)
            {
                Int32.TryParse(Request.QueryString["playlist_id"], out playlist_id);
            }

            hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.Member           member        = new hypster_tv_DAL.Member();
            member = memberManager.getMemberByUserName(User.Identity.Name);

            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.Playlist           curr_plst       = new hypster_tv_DAL.Playlist();
            curr_plst = playlistManager.GetUserPlaylistById(member.id, playlist_id);

            if (curr_plst.id != 0)
            {
                hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement();
                int tag_ID = 0;
                tag_ID  = tagManager.AddNewTag(tag_name);
                ret_res = tagManager.AddTagToPlaylist(tag_ID, playlist_id).ToString();
            }
            else
            {
                ret_res = "n/a";
            }

            return(ret_res);
        }
Example #19
0
        public ActionResult AddNewPlaylist(string AddPlaylist_Name)
        {
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();

            if (AddPlaylist_Name != "")
            {
                hypster_tv_DAL.Member member = new hypster_tv_DAL.Member();
                member = memberManager.getMemberByUserName(User.Identity.Name);

                hypster_tv_DAL.Playlist playlist = new hypster_tv_DAL.Playlist();
                playlist.name   = AddPlaylist_Name;
                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_man = new hypster_tv_DAL.Hypster_Entities();
                hyDB_man.Playlists.AddObject(playlist);
                hyDB_man.SaveChanges();

                hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement();
                List <hypster_tv_DAL.Playlist>    playlists_list     = playlistManagement.GetUserPlaylists(member.id);
                if (member.active_playlist == 0 && playlists_list.Count > 0)
                {
                    member.active_playlist = playlists_list[0].id;
                    memberManager.SetUserDefaultPlaylist(User.Identity.Name, member.id, member.active_playlist);
                }
            }
            return(RedirectPermanent("/Editors/managePlaylist/"));
        }
Example #20
0
        //--------------------------------------------------------------------------------------------------------

        //--------------------------------------------------------------------------------------------------------
        public string deletePlaylistTag()
        {
            string ret_res     = "";
            int    tag_plst_id = 0;

            if (Request.QueryString["tag_plst_id"] != null)
            {
                Int32.TryParse(Request.QueryString["tag_plst_id"], out tag_plst_id);
            }

            int playlist_id = 0;

            if (Request.QueryString["playlist_id"] != null)
            {
                Int32.TryParse(Request.QueryString["playlist_id"], out playlist_id);
            }

            hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.Member           member        = new hypster_tv_DAL.Member();
            member = memberManager.getMemberByUserName(User.Identity.Name);

            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.Playlist           curr_plst       = new hypster_tv_DAL.Playlist();
            curr_plst = playlistManager.GetUserPlaylistById(member.id, playlist_id);

            if (curr_plst.id != 0)
            {
                hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement();
                tagManager.DeletePlaylistTag(tag_plst_id);
                ret_res = "+";
            }
            else
            {
                ret_res = "n/a";
            }

            return(ret_res.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/"));
            }
        }
Example #22
0
        //----------------------------------------------------------------------------------------------------------
        // music player popup
        // this logic open player with playlists, songs, and other player related stuff
        public ActionResult Index()
        {
            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            //--------------------------------------------------------------------------------------------



            // 2.get requested media type (playlist, single song, default palylist)
            //--------------------------------------------------------------------------------------------
            string MEDIA_TYPE = "";

            if (Request.QueryString["media_type"] != null)
            {
                MEDIA_TYPE         = Request.QueryString["media_type"];
                ViewBag.MEDIA_TYPE = MEDIA_TYPE;
            }
            else
            {
                ViewBag.MEDIA_TYPE = "";
            }
            //--------------------------------------------------------------------------------------------



            hypster_tv_DAL.Member member = new hypster_tv_DAL.Member();
            if (Request.QueryString["us_id"] != null)
            {
                ViewBag.UserID = Request.QueryString["us_id"];
            }
            else
            {
                if (User.Identity.IsAuthenticated)
                {
                    member         = memberManager.getMemberByUserName(User.Identity.Name);
                    ViewBag.UserID = member.id;
                }
            }



            // 3.parse media type
            //--------------------------------------------------------------------------------------------
            hypster.ViewModels.videoPlayerViewModel model = new ViewModels.videoPlayerViewModel();

            switch (MEDIA_TYPE)
            {
            //
            //display requested playlist
            case "playlist":
                int PLAYLIST_ID = 0;
                if (Request.QueryString["playlist_id"] != null)
                {
                    if (Int32.TryParse(Request.QueryString["playlist_id"], out PLAYLIST_ID) == false)
                    {
                        PLAYLIST_ID = 0;
                    }
                }

                playlistManager.AddPlaylistView(PLAYLIST_ID);
                ViewBag.PlaylistID = PLAYLIST_ID;
                break;

            //
            //display single song
            case "":

                ViewBag.MEDIA_TYPE = "song";


                string SongGuid = "";
                if (Request.QueryString["song_guid"] != null)
                {
                    SongGuid         = Request.QueryString["song_guid"];
                    ViewBag.SongGuid = SongGuid.Replace("&", "amp;");
                }


                string SongTitle = "";
                if (Request.QueryString["song_title"] != null)
                {
                    SongTitle         = Request.QueryString["song_title"];
                    ViewBag.SongTitle = SongTitle.Replace("&", "amp;");
                }



                hypster_tv_DAL.PlaylistData_Song song = new hypster_tv_DAL.PlaylistData_Song();
                song.YoutubeId = SongGuid;
                song.Title     = SongTitle;

                model.songs_list.Add(song);



                if (model.songs_list.Count > 0)
                {
                    ViewBag.SongGuid = model.songs_list[0].YoutubeId;
                }
                break;



            //
            //display default palylist
            case "DEFPL":
                ViewBag.MEDIA_TYPE = "playlist";


                playlistManager.AddPlaylistView(member.active_playlist);
                ViewBag.PlaylistID = member.active_playlist;
                ViewBag.UserID     = member.id;
                break;



            //
            //display default palylist
            case "Radio":
                ViewBag.MEDIA_TYPE = "radio";


                string Genre_str = "";
                if (Request.QueryString["Genre"] != null)
                {
                    Genre_str     = Request.QueryString["Genre"];
                    Genre_str     = Genre_str.Replace("&", "amp;");
                    ViewBag.Genre = Genre_str;
                }

                string search_str = "";
                if (Request.QueryString["search"] != null)
                {
                    search_str     = Request.QueryString["search"];
                    ViewBag.search = search_str;
                }


                break;



            default:
                break;
            }
            //--------------------------------------------------------------------------------------------



            return(View(model));
        }
Example #23
0
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        // music player popup
        // this logic open player with playlists, songs, and other player related stuff
        public ActionResult MPL()
        {
            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            //--------------------------------------------------------------------------------------------



            // 2.get requested media type (playlist, single song, default palylist)
            //--------------------------------------------------------------------------------------------
            string MEDIA_TYPE = "";

            if (Request.QueryString["media_type"] != null)
            {
                MEDIA_TYPE         = Request.QueryString["media_type"];
                ViewBag.MEDIA_TYPE = MEDIA_TYPE;
            }
            else
            {
                ViewBag.MEDIA_TYPE = "";
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.Member member = new hypster_tv_DAL.Member();
            if (Request.QueryString["us_id"] != null)
            {
                ViewBag.UserID = Request.QueryString["us_id"];
                int us_id = 0;
                Int32.TryParse(Request.QueryString["us_id"], out us_id);
                if (us_id > 0)
                {
                    member = memberManager.getMemberByID(us_id);
                }
            }
            else
            {
                if (User.Identity.IsAuthenticated)
                {
                    member         = memberManager.getMemberByUserName(User.Identity.Name);
                    ViewBag.UserID = member.id;
                }
            }
            //--------------------------------------------------------------------------------------------



            // 3.parse media type
            //--------------------------------------------------------------------------------------------
            hypster.ViewModels.videoPlayerViewModel model = new ViewModels.videoPlayerViewModel();

            switch (MEDIA_TYPE)
            {
            //
            //display requested playlist
            case "playlist":
                int PLAYLIST_ID = 0;
                if (Request.QueryString["playlist_id"] != null)
                {
                    if (Int32.TryParse(Request.QueryString["playlist_id"], out PLAYLIST_ID) == false)
                    {
                        PLAYLIST_ID = 0;
                    }
                }

                playlistManager.AddPlaylistView(PLAYLIST_ID);

                if (ViewBag.UserID != null && PLAYLIST_ID != null)
                {
                    model.songs_list = playlistManager.GetSongsForPlayList(Int32.Parse(ViewBag.UserID.ToString()), (int)PLAYLIST_ID);
                }

                ViewBag.PlaylistID = PLAYLIST_ID;
                break;

            //
            //display single song
            case "":

                ViewBag.MEDIA_TYPE = "song";


                string SongGuid = "";
                if (Request.QueryString["song_guid"] != null)
                {
                    SongGuid         = Request.QueryString["song_guid"];
                    ViewBag.SongGuid = SongGuid.Replace("&", "amp;");
                }


                string SongTitle = "";
                if (Request.QueryString["song_title"] != null)
                {
                    SongTitle         = Request.QueryString["song_title"];
                    ViewBag.SongTitle = SongTitle.Replace("&", "amp;");
                }



                hypster_tv_DAL.PlaylistData_Song song = new hypster_tv_DAL.PlaylistData_Song();
                song.YoutubeId = SongGuid;
                song.Title     = SongTitle;

                model.songs_list.Add(song);



                if (model.songs_list.Count > 0)
                {
                    ViewBag.SongGuid = model.songs_list[0].YoutubeId;
                }
                break;



            //
            //display default palylist
            case "DEFPL":
                ViewBag.MEDIA_TYPE = "playlist";
                int PLAYLIST_ID_DEF = member.active_playlist;

                playlistManager.AddPlaylistView(member.active_playlist);

                if (ViewBag.UserID != null && PLAYLIST_ID_DEF != null)
                {
                    model.songs_list = playlistManager.GetSongsForPlayList(Int32.Parse(ViewBag.UserID.ToString()), (int)PLAYLIST_ID_DEF);
                }

                ViewBag.PlaylistID = member.active_playlist;
                ViewBag.UserID     = member.id;
                break;



            //
            //display default palylist
            case "Radio":
                ViewBag.MEDIA_TYPE = "radio";


                string Genre_str = "";
                if (Request.QueryString["Genre"] != null)
                {
                    Genre_str     = Request.QueryString["Genre"];
                    Genre_str     = Genre_str.Replace("&", "amp;");
                    ViewBag.Genre = Genre_str;
                }


                #region GET_RADIO_GENRE
                int G_User = 0;
                int G_Plst = 0;
                switch (Genre_str)
                {
                case "Dance":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Dance"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Dance"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Jazz":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Jazz"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Jazz"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Bluegrass":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Bluegrass"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Bluegrass"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Classical":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Classical"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Classical"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Reggae":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Reggae"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Reggae"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Rap":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Rap"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Rap"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Rock":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Rock"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Rock"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Soundtrack":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Soundtrack"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Soundtrack"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Blues":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Blues"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Blues"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Pop":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Pop"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Pop"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Country":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Country"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Country"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;



                case "Opera":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Opera"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Opera"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Hip-Hop":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_HipHop"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_HipHop"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Latin":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Latin"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Latin"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Electronic":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Electronic"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Electronic"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "R&B":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_RandB"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_RandB"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "NewAge":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_NewAge"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_NewAge"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Folk":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Folk"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Folk"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "J-Pop":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_JPop"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_JPop"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Soul":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Soul"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Soul"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Instrumental":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Instrumental"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Instrumental"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Adult Contemporary":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_AdultContemp"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_AdultContemp"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;

                case "Alternative":
                    G_User = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_User_Alternative"]);
                    G_Plst = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["Radio_Plst_Alternative"]);
                    playlistManager.AddPlaylistView(member.active_playlist);
                    model.songs_list = playlistManager.GetSongsForPlayList(G_User, G_Plst);
                    break;



                default:         //if custom search started

                    string search_str = "";
                    if (Request.QueryString["search"] != null)
                    {
                        search_str     = Request.QueryString["search"];
                        ViewBag.search = search_str;
                    }
                    YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA");
                    YouTubeRequest         request  = new YouTubeRequest(settings);

                    int this_page = 1;
                    for (this_page = 1; this_page < 10; this_page++)
                    {
                        string       feedUrl   = "http://gdata.youtube.com/feeds/api/videos?q=" + Genre_str + "&category=Music&format=5&restriction=" + Request.ServerVariables["REMOTE_ADDR"] + "&safeSearch=none&start-index=" + ((this_page * 25) - 24) + "&orderby=viewCount";
                        Feed <Video> videoFeed = request.Get <Video>(new Uri(feedUrl));
                        foreach (Video item in videoFeed.Entries)
                        {
                            hypster_tv_DAL.PlaylistData_Song song_add1 = new hypster_tv_DAL.PlaylistData_Song();
                            song_add1.YoutubeId = item.VideoId;
                            song_add1.Title     = item.Title;
                            model.songs_list.Add(song_add1);
                        }
                    }
                    break;
                }
                #endregion

                ViewBag.UserID     = G_User;
                ViewBag.PlaylistID = G_Plst;



                break;



            default:
                break;
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            if (member.id != 0)
            {
                model.userPlaylists_list = playlistManager.GetUserPlaylists(member.id);
            }
            //--------------------------------------------------------------------------------------------



            return(View(model));
        }
Example #24
0
        public ActionResult getPlayer(string id)
        {
            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.playerManagement   playerManager   = new hypster_tv_DAL.playerManagement();
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            hypster.ViewModels.GetPlayerViewModel model = new ViewModels.GetPlayerViewModel();
            model.curr_user      = memberManager.getMemberByUserName(User.Identity.Name);
            model.playlists_list = playlistManager.GetUserPlaylists(model.curr_user.id);
            //--------------------------------------------------------------------------------------------



            //*******Check ACTION***********************************
            if (Request.QueryString["ACT"] != null)
            {
                switch (Request.QueryString["ACT"])
                {
                case "DeletePlayer":

                    int i_player_id = 0;
                    if (Request.QueryString["Pl_ID"] != null && Int32.TryParse(Request.QueryString["Pl_ID"], out i_player_id) == false)
                    {
                        i_player_id = 0;
                    }


                    if (i_player_id != 0)
                    {
                        playerManager.DeletePlayer(model.curr_user.id, i_player_id);
                        return(RedirectPermanent("/account/music"));
                    }

                    break;

                default:
                    break;
                }
            }
            //******************************************************



            switch (id)
            {
            case "BarPlayer":
                //get player for editing if exist
                int player_ID1 = 0;
                if (Request.QueryString["Pl_ID"] != null)
                {
                    if (Int32.TryParse(Request.QueryString["Pl_ID"], out player_ID1) == false)
                    {
                        player_ID1 = 0;
                    }
                    if (player_ID1 != 0)
                    {
                        model.player = playerManager.GetPlayerByID(model.curr_user.id, player_ID1);
                    }
                }


                return(View("getPlayer_Bar", model));

                break;

            case "ClassicPlayer":
                //get player for editing if exist
                int player_ID2 = 0;
                if (Request.QueryString["Pl_ID"] != null)
                {
                    if (Int32.TryParse(Request.QueryString["Pl_ID"], out player_ID2) == false)
                    {
                        player_ID2 = 0;
                    }
                    if (player_ID2 != 0)
                    {
                        model.player = playerManager.GetPlayerByID(model.curr_user.id, player_ID2);
                    }
                }

                return(View("getPlayer_Classic", model));

                break;


            case "RadioPlayer":
                //get player for editing if exist

                hypster.ViewModels.GetPlayerViewModel model_Radio = new ViewModels.GetPlayerViewModel();

                int player_ID3 = 0;
                if (Request.QueryString["Pl_ID"] != null)
                {
                    if (Int32.TryParse(Request.QueryString["Pl_ID"], out player_ID3) == false)
                    {
                        player_ID3 = 0;
                    }
                    if (player_ID3 != 0)
                    {
                        model_Radio.player = playerManager.GetPlayerByID(model.curr_user.id, player_ID3);
                    }
                }

                hypster_tv_DAL.MemberMusicGenreManager genreMeneger = new hypster_tv_DAL.MemberMusicGenreManager();
                model_Radio.music_genres_list = genreMeneger.GetMusicGenresList();

                return(View("getPlayer_Radio", model_Radio));

                break;

            default:
                break;
            }


            return(View());
        }
Example #25
0
        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));
            //--------------------------------------------------------------------------------------------------------------------
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        //authentitication implemented inside (ajax call)
        public ActionResult AddToPlayListPopup()
        {
            //--------------------------------------------------------------------------------------------
            if (User.Identity.IsAuthenticated == false)
            {
                return(Content(""));
            }
            //--------------------------------------------------------------------------------------------



            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement();
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            hypster.ViewModels.AddToPlayListViewModel model = new ViewModels.AddToPlayListViewModel();

            //get curr user
            hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member();
            curr_user = userManager.getMemberByUserName(User.Identity.Name);


            if (Request.QueryString["song_title"] != null)
            {
                ViewBag.song_title = Request.QueryString["song_title"];
            }

            if (Request.QueryString["song_guid"] != null)
            {
                ViewBag.song_guid = Request.QueryString["song_guid"];
            }


            int PLAYLIST_ID = 0;

            PLAYLIST_ID = curr_user.active_playlist;

            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            model.songs_list = playlistManager.GetSongsForPlayList(curr_user.id, PLAYLIST_ID);

            model.playlists_list = playlistManager.GetUserPlaylists(curr_user.id);

            model.curr_user = curr_user;
            //--------------------------------------------------------------------------------------------



            // NEED TO CHECK HERE
            //--------------------------------------------------------------------------------------------
            foreach (var item in model.playlists_list)
            {
                if (PLAYLIST_ID == item.id)
                {
                    ViewBag.Playlist_ID   = item.id;
                    ViewBag.Playlist_Name = item.name;
                }
            }
            //--------------------------------------------------------------------------------------------



            return(View(model));
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        // apply order to playlist songs
        //
        //authentitication implemented inside (ajax call)
        public string applyOrder()
        {
            //--------------------------------------------------------------------------------------------
            if (User.Identity.IsAuthenticated == false)
            {
                return("not authorized");
            }
            //--------------------------------------------------------------------------------------------



            // 1.parse parameters
            //--------------------------------------------------------------------------------------------
            int  SONG_ID       = 0;
            int  SONG_ORDER    = 0;
            int  ACTIVE_PL     = 0;
            bool params_parsed = true;

            if (Request.QueryString["SONG_ID"] != null && Int32.TryParse(Request.QueryString["SONG_ID"], out SONG_ID) == false)
            {
                params_parsed = false;
            }

            if (Request.QueryString["SONG_ORDER"] != null && Int32.TryParse(Request.QueryString["SONG_ORDER"], out SONG_ORDER) == false)
            {
                params_parsed = false;
            }

            if (Request.QueryString["ACTIVE_PL"] != null && Int32.TryParse(Request.QueryString["ACTIVE_PL"], out ACTIVE_PL) == false)
            {
                params_parsed = false;
            }
            //--------------------------------------------------------------------------------------------



            //--------------------------------------------------------------------------------------------
            if (params_parsed == true)
            {
                hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();
                hypster_tv_DAL.Member           curr_user     = new hypster_tv_DAL.Member();
                curr_user = memberManager.getMemberByUserName(User.Identity.Name);


                hypster_tv_DAL.playlistManagement       playlistsManagement = new hypster_tv_DAL.playlistManagement();
                List <hypster_tv_DAL.PlaylistData_Song> songs_list          = new List <hypster_tv_DAL.PlaylistData_Song>();
                songs_list = playlistsManagement.GetSongsForPlayList(curr_user.id, ACTIVE_PL);



                int UPD_INDEX = -1;
                int i_count   = 0;
                hypster_tv_DAL.PlaylistData_Song i_currSong = new hypster_tv_DAL.PlaylistData_Song();



                //2. find position of where new link will be located
                //**************************************************************************************************************************
                i_count = 0;
                foreach (hypster_tv_DAL.PlaylistData_Song item in songs_list)
                {
                    if (item.playlist_track_id == SONG_ID)
                    {
                        int add_ind = 0;
                        if (SONG_ORDER > 0)
                        {
                            add_ind = 1;
                        }


                        UPD_INDEX  = i_count + SONG_ORDER + add_ind;
                        i_currSong = item;

                        break;
                    }

                    i_count++;
                }
                //**************************************************************************************************************************



                bool update_order = false;


                //3. get to position of new element and start updating new order
                //**************************************************************************************************************************
                List <hypster_tv_DAL.PlaylistData_Song> upd_links_arr = new List <hypster_tv_DAL.PlaylistData_Song>();
                i_count = 0;
                foreach (hypster_tv_DAL.PlaylistData_Song ii_item in songs_list)
                {
                    //inc next items order
                    if (update_order == true)
                    {
                        if (ii_item.playlist_track_id != SONG_ID)
                        {
                            ii_item.sortid += 1;
                            upd_links_arr.Add(ii_item);
                        }
                    }


                    //find start element
                    if (UPD_INDEX == i_count)
                    {
                        i_currSong.sortid = ii_item.sortid;
                        upd_links_arr.Add(i_currSong);
                        update_order = true;


                        ii_item.sortid += 1;
                        upd_links_arr.Add(ii_item);
                    }


                    i_count++;
                }
                playlistsManagement.Update_CustomOrder(curr_user.id, upd_links_arr);
                //**************************************************************************************************************************
            }
            //--------------------------------------------------------------------------------------------



            return("true");
        }
        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"));
            //-----------------------------------------------------------------------------------------
        }
Example #29
0
        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));
        }
Example #30
0
        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/"));
        }