public ActionResult Playlist(NameValueCollection nvc) { mu = Membership.GetUser(); ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey)); ViewBag.UserName = ua.UserName; BootBaronLib.AppSpec.DasKlub.BOL.Playlist plyst = new Playlist(); plyst.GetUserPlaylist(ua.UserAccountID); ViewBag.UserPlaylistID = plyst.PlaylistID; PlaylistVideos plyvids = new PlaylistVideos(); plyvids.GetPlaylistVideosForPlaylist(plyst.PlaylistID); nvc = Request.Form; //video_delete_id //video_down_id //video_up_id PlaylistVideo plv = null; if (nvc["video_delete_id"] != null) { foreach (PlaylistVideo plv1 in plyvids) { if (plv != null && plv1.RankOrder > plv.RankOrder) { plv1.RankOrder--; plv1.UpdatedByUserID = ua.UserAccountID; plv1.Update(); } if (plv1.PlaylistID == plyst.PlaylistID && Convert.ToInt32(nvc["video_delete_id"]) == plv1.VideoID) { plv = new PlaylistVideo(plv1.PlaylistVideoID); if (PlaylistVideo.Delete(plyst.PlaylistID, Convert.ToInt32(nvc["video_delete_id"]))) { // deleted } } } } else if (nvc["video_down_id"] != null) { plv = new PlaylistVideo(); plv.Get(plyst.PlaylistID, Convert.ToInt32(nvc["video_down_id"])); foreach (PlaylistVideo plv1 in plyvids) { if (plv1.RankOrder == (plv.RankOrder + 1)) { plv1.RankOrder--; plv1.UpdatedByUserID = ua.UserAccountID; plv1.Update(); } } plv.RankOrder++; plv.UpdatedByUserID = ua.UserAccountID; plv.Update(); } else if (nvc["video_up_id"] != null) { plv = new PlaylistVideo(); plv.Get(plyst.PlaylistID, Convert.ToInt32(nvc["video_up_id"])); foreach (PlaylistVideo plv1 in plyvids) { if (plv1.RankOrder == (plv.RankOrder - 1)) { plv1.RankOrder++; plv1.UpdatedByUserID = ua.UserAccountID; plv1.Update(); } } plv.RankOrder--; plv.UpdatedByUserID = ua.UserAccountID; plv.Update(); } else //if (nvc["selected_autoplay"] != null) { if (!string.IsNullOrEmpty(nvc["selected_autoplay"]) && nvc["selected_autoplay"] == "on") { plyst.AutoPlay = true; } else plyst.AutoPlay = false; plyst.Update(); } Response.Redirect("~/account/playlist"); return new EmptyResult(); }
public ActionResult Playlist(NameValueCollection nvc) { if (nvc == null) throw new ArgumentNullException("nvc"); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.UserName = _ua.UserName; var plyst = new Playlist(); plyst.GetUserPlaylist(_ua.UserAccountID); ViewBag.UserPlaylistID = plyst.PlaylistID; var plyvids = new PlaylistVideos(); plyvids.GetPlaylistVideosForPlaylist(plyst.PlaylistID); nvc = Request.Form; PlaylistVideo plv = null; if (nvc["video_delete_id"] != null) { foreach (PlaylistVideo plv1 in plyvids) { if (plv != null && plv1.RankOrder > plv.RankOrder) { plv1.RankOrder--; plv1.UpdatedByUserID = _ua.UserAccountID; plv1.Update(); } if (plv1.PlaylistID != plyst.PlaylistID || Convert.ToInt32(nvc["video_delete_id"]) != plv1.VideoID) continue; plv = new PlaylistVideo(plv1.PlaylistVideoID); if (PlaylistVideo.Delete(plyst.PlaylistID, Convert.ToInt32(nvc["video_delete_id"]))) { // deleted } } } else if (nvc["video_down_id"] != null) { plv = new PlaylistVideo(); plv.Get(plyst.PlaylistID, Convert.ToInt32(nvc["video_down_id"])); foreach (PlaylistVideo plv1 in plyvids.Where(plv1 => plv1.RankOrder == (plv.RankOrder + 1))) { plv1.RankOrder--; plv1.UpdatedByUserID = _ua.UserAccountID; plv1.Update(); } plv.RankOrder++; plv.UpdatedByUserID = _ua.UserAccountID; plv.Update(); } else if (nvc["video_up_id"] != null) { plv = new PlaylistVideo(); plv.Get(plyst.PlaylistID, Convert.ToInt32(nvc["video_up_id"])); foreach (PlaylistVideo plv1 in plyvids.Where(plv1 => plv1.RankOrder == (plv.RankOrder - 1))) { plv1.RankOrder++; plv1.UpdatedByUserID = _ua.UserAccountID; plv1.Update(); } plv.RankOrder--; plv.UpdatedByUserID = _ua.UserAccountID; plv.Update(); } else { if (!string.IsNullOrEmpty(nvc["selected_autoplay"]) && nvc["selected_autoplay"] == "on") { plyst.AutoPlay = true; } else plyst.AutoPlay = false; plyst.Update(); } Response.Redirect("~/account/playlist"); return new EmptyResult(); }