Esempio n. 1
0
        public async Task<IActionResult> Category(int id = 0, string slug = "", int p = 1)
        {
            if (id == 0 || string.IsNullOrEmpty(slug))
            {
                return Redirect("/");
            }
            if (p <= 0) p = 1;

            var data = new PostData(Db);
            var model = await data.GetByCategoryAsync(id, p);
            if (model == null) Redirect("/");
            ViewBag.PageCount = data.PageCount;
            ViewBag.PageNo = p;
            ViewBag.PagingUrl = $"/Category/{id}/{slug}?p={{p}}";

            return View("/Views/Home/Index", model);
        }