Пример #1
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));
        }
Пример #2
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/"));
        }
Пример #3
0
        public ActionResult delelePlaylistSong()
        {
            hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel model = new hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel();
            hypster_tv_DAL.memberManagement   memberManager   = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement();
            hypster_tv_DAL.memberManagement   userManager     = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.songsManagement    songsManager    = new hypster_tv_DAL.songsManagement();
            model.member = memberManager.getMemberByUserName(User.Identity.Name);

            if (Request.QueryString["ACT"] != null)
            {
                switch (Request.QueryString["ACT"].ToString())
                {
                case "delete_playlist":
                    int d_playlist_id = 0;
                    if (Int32.TryParse(Request.QueryString["playlist_id"], out d_playlist_id) == false)
                    {
                        d_playlist_id = 0;
                    }
                    if (d_playlist_id != 0)
                    {
                        playlistManager.Delete_Playlist(model.member.id, d_playlist_id);
                        //check if this playlist is default
                        if (model.member.active_playlist == d_playlist_id)
                        {
                            memberManager.SetUserDefaultPlaylist(User.Identity.Name, model.member.id, 0);
                        }
                        return(RedirectPermanent("/Editors/managePlaylist/"));
                    }
                    break;

                case "delete_song":
                    int d_song_id = 0;
                    if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id) == false)
                    {
                        d_song_id = 0;
                    }
                    string pl_id = "";
                    if (Request.QueryString["playlist_id"] != null)
                    {
                        pl_id = Request.QueryString["playlist_id"].ToString();
                    }
                    if (d_song_id != 0)
                    {
                        playlistManager.DeleteSong(model.member.id, d_song_id);
                        return(RedirectPermanent("/Editors/managePlaylist/?playlist_id=" + pl_id));
                    }
                    break;

                case "delete_song_plr":
                    int d_song_id1 = 0;
                    if (Int32.TryParse(Request.QueryString["song_id"], out d_song_id1) == false)
                    {
                        d_song_id1 = 0;
                    }

                    if (d_song_id1 != 0)
                    {
                        playlistManager.DeleteSong(model.member.id, d_song_id1);
                        return(RedirectPermanent("/Editors/managePlaylist/"));
                    }
                    break;

                default:
                    break;
                }
            }

            model.playlist = playlistManager.GetUserPlaylists(model.member.id);

            int playlist_id = 0;

            if (Request.QueryString["playlist_id"] != null)
            {
                if (Int32.TryParse(Request.QueryString["playlist_id"], out playlist_id) == false)
                {
                    playlist_id = 0;
                }
            }
            else
            {
                playlist_id = model.member.active_playlist;
            }

            foreach (var item in model.playlist)
            {
                if (item.id == playlist_id)
                {
                    ViewBag.ActivePlaylistName = item.name;
                    ViewBag.ActivePlaylistID   = item.id;
                }
            }

            if (playlist_id != 0)
            {
                model.playlistData_Song = playlistManager.GetSongsForPlayList(model.member.id, playlist_id);
            }
            else
            {
                model.playlistData_Song = playlistManager.GetSongsForPlayList(model.member.id, model.member.active_playlist);
            }

            hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement();
            if (playlist_id != 0)
            {
                model.tags_list = tagManager.GetPlaylistTags(playlist_id);
            }
            else
            {
                model.tags_list = tagManager.GetPlaylistTags(model.member.active_playlist);
            }

            return(View(model));
        }