GetArticleIndex() public method

public GetArticleIndex ( ) : ArticleIndex
return Postworthy.Models.Web.ArticleIndex
Ejemplo n.º 1
0
        public ActionResult Details(uint id, string slug, bool seo = false)
        {
            Article article = null;

            var model = new PostworthyArticleModel(PrimaryUser);

            if (slug != "p" && seo == true)
            {
                article = model.GetArticle(id);
                if (article != null)
                    ViewBag.RelatedArticles = model
                        .Articles(x =>
                            x.ID() != article.ID() &&
                            x.Tags.Any(y =>
                                article.Tags.Where(z =>
                                    z.ToLower() == y.ToLower()).Any()))
                        .Where(x => x != null)
                        .Take(3)
                        .ToList();
                else
                    ViewBag.RelatedArticles = null;
            }
            else if(slug == "p")
            {
                var oldURL = (Session[id.ToString()] ?? id.ToString()).ToString().ToLower();

                if (!string.IsNullOrEmpty(oldURL))
                {
                    article = model.Articles(x => x.MetaData.Where(y =>
                        y.Key == OLD_URL &&
                        (
                            y.Value.ToLower() == oldURL ||
                            y.Value.ToLower().EndsWith("?p="+id.ToString())  ||
                            y.Value.ToLower().EndsWith("?id="+id.ToString())
                        )).Any())
                        .FirstOrDefault();

                    if (article != null)
                        return RedirectPermanent("~/article/" + article.GetSlug() + "_" + article.ID());
                }
            }
            else if(!seo)
            {
                article = model.GetArticle(id);
                return RedirectPermanent("~/article/" + article.GetSlug() + "_" + article.ID());
            }

            if (article != null)
            {
                article.Tags = article.Tags.Select(x => GetTagLink(x)).ToList();
                ViewBag.Tags = model.GetArticleIndex().Articles.SelectMany(x => x.Tags).Distinct().Select(x => GetTagLink(x));
                return View(article);
            }
            else
                return RedirectToAction("Index", new { id = 0 });
        }
Ejemplo n.º 2
0
        public ActionResult Index(int id = 0, string slug = "")
        {
            slug = slug.ToLower();
            ViewBag.Slug = slug;
            ViewBag.Page = id;
            ViewBag.PageSize = PAGE_SIZE;

            var model = new PostworthyArticleModel(PrimaryUser);
            int pageCount = 0;
            var viewModel = model.PagedArticles(PAGE_SIZE * id, PAGE_SIZE, slug, out pageCount);

            ViewBag.Tags = model.GetArticleIndex().Articles.SelectMany(x => x.Tags).Distinct().Select(x => GetTagLink(x));
            ViewBag.PageCount = pageCount;

            return View(viewModel);
        }
Ejemplo n.º 3
0
 public ActionResult Admin()
 {
     var model = new PostworthyArticleModel(PrimaryUser);
     return View(model.GetArticleIndex());
 }
Ejemplo n.º 4
0
        public ActionResult Index(DateTime? id = null, string slug = null)
        {
            var p = Request.QueryString["p"];
            if (!string.IsNullOrEmpty(p))
            {
                Session[p] = Request.Url.ToString();
                return RedirectToAction("Details", "Article", new { id = p, slug = "p" });
            }

            if (Request.Url.ToString().ToLower().Contains("/home/article?id=") || Request.Url.ToString().ToLower().Contains("/home/article/?id="))
            {
                Session[Request.QueryString["id"]] = Request.Url.ToString();
                return RedirectToAction("Details", "Article", new { id = Request.QueryString["id"], slug = "p" });
            }

            DateTime date = DateTime.Now;
            if (id.HasValue)
            {
                date = id.Value;
                if (!string.IsNullOrEmpty(slug))
                {
                    switch (slug)
                    {
                        case PHOTOS_SLUG:
                            return Photos(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null);
                        case VIDEOS_SLUG:
                            return Videos(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null);
                        default:
                            return Video(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null, slug);
                    }
                }
            }

            var model = new PostworthyArticleModel(PrimaryUser);
            var articles = model.GetArticleIndex();

            if (articles.Articles.Count >= 5 && !id.HasValue && PrimaryUser.EnableFrontPage)
                return FrontPage();

            ViewBag.Date = date;
            ViewBag.ArticleStubIndex = model.GetArticleStubIndex();
            ViewBag.ArticlesIndex = articles;

            return View(model.GetArticleStubPage(date));
        }