コード例 #1
0
        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/"));
            }
        }
コード例 #2
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);
        }
コード例 #3
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());
        }