Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            VideoModel model = new VideoModel();

            VideoService videoService = new VideoService();
            model.Video = videoService.GetVideoById(id);

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Index(string keywords, string page)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            VideoModel model = new VideoModel();

            VideoService videoService = new VideoService();

            int tempPage = 1;

            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out tempPage);
            }

            //视频列表
            int tempCount = 0;
            model.Videos = videoService.GetVideos(keywords, 15, tempPage, out tempCount);
            //分页
            if (model.Videos != null && model.Videos.Count > 0)
            {
                model.PageIndex = tempPage;
                model.PageSize = 15;
                model.PageStep = 10;
                model.AllCount = tempCount;
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            model.Keywords = keywords;

            return View(model);
        }