Ejemplo n.º 1
0
        public ActionResult Index(VideoIndexModel model, int?page)
        {
            int               defautPagesize   = 10;
            int               total            = 0;
            int               currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            IVideosService    videoSrv         = IoC.Resolve <IVideosService>();
            IVideoTypeService videotypeSrv     = IoC.Resolve <IVideoTypeService>();

            model.VideoTypes = videotypeSrv.Query.OrderBy(p => p.NameVNI).OrderBy(p => p.NameENG).ToList();
            string         kw       = String.IsNullOrWhiteSpace(model.Keyword) ? null : model.Keyword.Trim();
            IList <Videos> list     = new List <Videos>();
            string         username = HttpContext.User.Identity.Name;

            model.TypeID = string.IsNullOrWhiteSpace(model.TypeID) ? "0" : model.TypeID;
            int cID = 0;

            int.TryParse(model.TypeID, out cID);
            if (HttpContext.User.IsInRole("Root"))
            {
                list = videoSrv.GetBySearch(kw, cID, currentPageIndex, defautPagesize, out total);
            }
            else
            {
                list = videoSrv.GetBySearch(kw, cID, username, currentPageIndex, defautPagesize, out total);
            }

            model.Videos = new PagedList <Videos>(list, currentPageIndex, defautPagesize, total);
            return(View(model));
        }