Example #1
0
        public IActionResult Index(string url, int?pageSize, string sortBy, int trang = 1)
        {
            var catalog = new PostListByCategoryViewModel();

            if (pageSize == null)
            {
                pageSize = _configuration.GetValue <int>("PageSize");
            }

            //pageSize = 10;
            catalog.PageSize = pageSize;
            catalog.SortType = sortBy;

            var category   = _postCategoryService.GetByUrl(url);
            var categoryId = category.Id;

            //ViewBag.CategoryName = category.Name;
            //ViewBag.MetaTitle = category.MetaTitle;
            //ViewBag.MetaDescription = category.MetaDescription;
            //ViewBag.MetaKeywords = category.MetaKeywords;
            //ViewBag.Url = category.Url;
            //var list = _postService.GetAllByCategoryId(categoryId);

            catalog.Data     = _postService.GetAllPaging(categoryId, string.Empty, trang, pageSize.Value);
            catalog.Category = category;
            return(View(catalog));
        }