コード例 #1
0
        public ActionResult ChuyenMuc(string _searchKey, int?_parentId, int?_pageIndex)
        {
            var _user = _db.UserLogins.Find(User.Identity.Name);

            if (_user != null && _user.sessionId != HttpContext.Session.SessionID)
            {
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            }

            ContentView result;
            int         _languageId = 1;

            result = _services.GetAllAdmin(_searchKey, null, null, _parentId, "ChuyenMucTinTuc", _languageId, false, _pageIndex, 20);
            int totalPage = result?.Total ?? 0;

            ViewBag.TotalPage = totalPage;
            ViewBag.PageIndex = _pageIndex ?? 1;
            ViewBag.SearchKey = string.IsNullOrWhiteSpace(_searchKey) ? string.Empty : _searchKey;
            IEnumerable <DropdownModel> category = _services.Dropdownlist(_parentId.GetValueOrDefault(), null, "ChuyenMucTinTuc", 1);

            ViewBag._parentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(result.ViewContents));
        }
コード例 #2
0
        public ActionResult Index(string _searchKey, int?_parentId, int?_pageIndex)
        {
            ContentView result;

            result = _services.GetAllAdmin(_searchKey, null, null, _parentId, "CHUYENMUCTINTUC", 1, false, _pageIndex, 20);
            int totalPage = result?.Total ?? 0;

            ViewBag.TotalPage = totalPage;
            ViewBag.PageIndex = _pageIndex ?? 1;
            ViewBag.SearchKey = string.IsNullOrWhiteSpace(_searchKey) ? string.Empty : _searchKey;
            IEnumerable <DropdownModel> category = _services.Dropdownlist(_parentId.GetValueOrDefault(), null, "CHUYENMUCTINTUC", 1);

            ViewBag._parentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            if (result != null && result.ViewContents.Count() > 0)
            {
                IEnumerable <ModelChuyenMuc> model = result.ViewContents.Select(x => new ModelChuyenMuc
                {
                    Link            = x.contentAlias,
                    Id              = x.contentId,
                    Thumbnail       = x.contentThumbnail,
                    MetaDescription = x.contentDescription,
                    MetaKeywords    = x.contentMetaKeywords,
                    MetaTitle       = x.contentMetaTitle,
                    Name            = x.contentName,
                    Note            = x.contentDescription,
                    ParentId        = x.contentParentId
                });
                return(View(model));
            }
            else
            {
                List <ModelChuyenMuc> model = new List <ModelChuyenMuc>();
                return(View(model));
            }
        }