GetArticle() public method

public GetArticle ( uint id ) : Article
id uint
return Postworthy.Models.Web.Article
Ejemplo n.º 1
0
 public ActionResult TwitterCardMeta(uint id, string slug)
 {
     var model = new PostworthyArticleModel(PrimaryUser);
     return View(model.GetArticle(id));
 }
Ejemplo n.º 2
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.º 3
0
        public ActionResult Edit(string id)
        {
            var model = new PostworthyArticleModel(PrimaryUser);
            var article = model.GetArticle(id.GetUintHashCode());

            if (article != null)
                return View("Create", article);
            else
                return RedirectToAction("Admin", new { id = PrimaryUser.TwitterScreenName });
        }