public ActionResult Edit(PlayList playlist)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    playlist = FillNulls(playlist);

                    string validation = ValidateInput(playlist, Request.Form["txtPlayListVideos"].ToString());
                    if (!String.IsNullOrEmpty(validation))
                    {
                        ViewData["ValidationMessage"] = validation;
                        ViewData["VideoList"]         = new SelectList(BuildVideoList(), "Value", "Text", "");
                        ViewData["VideoUrl"]          = firstfile;
                        ViewData["PlayListVideos"]    = Request.Form["txtPlayListVideos"].ToString();
                        ViewData["PlayListVideoList"] = new SelectList(BuildPlayListVideoList(Request.Form["txtPlayListVideos"].ToString()), "Value", "Text", "");

                        // Get the account id
                        int accountid = 0;
                        if (Session["UserAccountID"] != null)
                        {
                            accountid = Convert.ToInt32(Session["UserAccountID"]);
                        }
                        ViewData["VideoFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Videos/";
                        return(View(playlist));
                    }
                    else
                    {
                        // Update the playlist
                        repository.UpdatePlayList(playlist);

                        CommonMethods.CreateActivityLog((User)Session["User"], "Play List", "Edit",
                                                        "Edited play list '" + playlist.PlayListName + "' - ID: " + playlist.PlayListID.ToString());

                        IPlayListVideoXrefRepository xrefrep = new EntityPlayListVideoXrefRepository();
                        IVideoRepository             vidrep  = new EntityVideoRepository();

                        // Delete existing xrefs for the playlist
                        xrefrep.DeletePlayListVideoXrefs(playlist.PlayListID);

                        // Create a xref for each video in the playlist
                        string[] guids = Request.Form["txtPlayListVideos"].ToString().Split('|');
                        int      i     = 1;
                        foreach (string guid in guids)
                        {
                            if (!String.IsNullOrEmpty(guid.Trim()))
                            {
                                Video vid = vidrep.GetVideoByGuid(Convert.ToInt32(Session["UserAccountID"]), guid);
                                if (vid != null)
                                {
                                    PlayListVideoXref xref = new PlayListVideoXref();
                                    xref.PlayOrder  = i;
                                    xref.PlayListID = playlist.PlayListID;
                                    xref.VideoID    = vid.VideoID;
                                    xrefrep.CreatePlayListVideoXref(xref);
                                    i += 1;
                                }
                            }
                        }
                        return(RedirectToAction("Index"));
                    }
                }

                return(View(playlist));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayList", "Edit POST", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }
 public IActionResult UpdatePlayList(UpdatePlayListRequest data)
 {
     return(Ok(repository.UpdatePlayList(data)));
 }