Esempio n. 1
0
        public ActionResult Index(string slug = "", int year = 0, int month = 0, int page = 0)
        {
            ViewBag.CurrentLanguage = CurrentLanguage;
            if (!string.IsNullOrEmpty(slug))
            {
                var post = _nccPostService.GetBySlug(slug);
                if (post != null)
                {
                    post = _mediator.FirePostEvent(post, PostEvent.Show, null, _logger);
                    SetShortCodeContent(post);
                    return(View("Details", post));
                }
                TempData["Message"] = "Post not found";
            }
            DateTime?dateFrom = null;
            DateTime?dateTo   = null;

            if (year > 0 && month > 0)
            {
                dateFrom = new DateTime(year, month, 1);
                dateTo   = dateFrom?.AddMonths(1).AddMinutes(-1);
            }
            else if (year > 0)
            {
                dateFrom = new DateTime(year, 1, 1);
                dateTo   = dateFrom?.AddYears(1).AddMinutes(-1);
            }
            var postPerPage = GlobalContext.WebSite.WebSitePageSize;
            var totalPost   = _nccPostService.Count(true, true, true, true, dateFrom, dateTo);
            var allPost     = _nccPostService.Load(page, postPerPage, true, true, true, true, dateFrom, dateTo, 0, 0, 0, "", "PublishDate", "desc");

            for (int i = 0; i < allPost.Count; i++)
            {
                allPost[i] = _mediator.FirePostEvent(allPost[i], PostEvent.Show);
            }

            ViewBag.CurrentPage = page;
            ViewBag.PostPerPage = postPerPage;
            ViewBag.TotalPost   = totalPost;
            return(View(allPost));
        }
Esempio n. 2
0
        public ActionResult Index(string slug = "", int page = 0)
        {
            ViewBag.CurrentLanguage = CurrentLanguage;
            if (!string.IsNullOrEmpty(slug))
            {
                var post = _nccPostService.GetBySlug(slug);
                if (post != null)
                {
                    post = _mediator.Send(new OnPostShow(post)).Result;
                    SetShortCodeContent(post);
                    return(View("Details", post));
                }
                TempData["Message"] = "Post not found";
            }
            var allPost = _nccPostService.LoadPublished(page);

            for (int i = 0; i < allPost.Count; i++)
            {
                allPost[i] = _mediator.Send(new OnPostShow(allPost[i])).Result;
            }
            return(View(allPost));
        }