Пример #1
0
        //
        // GET: /PlayList/Edit/5

        public ActionResult Edit(int id)
        {
            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";
                }

                PlayList playlist = repository.GetPlayList(id);
                ViewData["ValidationMessage"] = String.Empty;
                ViewData["VideoList"]         = new SelectList(BuildVideoList(), "Value", "Text", "");
                ViewData["VideoUrl"]          = firstfile;

                // Get the video guids for the playlist
                string guids = String.Empty;
                IPlayListVideoXrefRepository    xrefrep = new EntityPlayListVideoXrefRepository();
                IVideoRepository                imgrep  = new EntityVideoRepository();
                IEnumerable <PlayListVideoXref> xrefs   = xrefrep.GetPlayListVideoXrefs(id);
                foreach (PlayListVideoXref xref in xrefs)
                {
                    Video vid = imgrep.GetVideo(xref.VideoID);
                    guids += "|" + vid.StoredFilename;
                }

                ViewData["PlayListVideos"]    = guids;
                ViewData["PlayListVideoList"] = new SelectList(BuildPlayListVideoList(guids), "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));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayList", "Edit", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }