Пример #1
0
        public async Task <IActionResult> OnGetAsync(string slug)
        {
            // TODO: If topicName not specified, default to Home Page

            slug    = slug ?? "home-page";
            Article = await _articleRepo.GetArticleBySlug(slug);

            if (Article == null)
            {
                Slug = slug;
                var historical = await _slugHistoryRepo.GetSlugHistoryWithArticle(slug);

                if (historical != null)
                {
                    return(new RedirectResult($"~/{historical.Article.Slug}"));
                }
                else
                {
                    return(new ArticleNotFoundResult(slug));
                }
            }

            if (Request.Cookies[Article.Topic] == null)
            {
                Article.ViewCount++;
                Response.Cookies.Append(Article.Topic, "foo", new Microsoft.AspNetCore.Http.CookieOptions
                {
                    Expires = DateTime.UtcNow.AddMinutes(5)
                });
            }

            return(Page());
        }
Пример #2
0
 public async Task <SlugHistoryDto> GetSlugHistoryWithArticle(string slug)
 {
     return(_mapper.Map <SlugHistoryDto>(await _slugHistoryRepository.GetSlugHistoryWithArticle(slug)));
 }