コード例 #1
0
        public ActionResult Post(string title)
        {
            var config = LoadConfig();
            var index  = IndexOfPost(config.Posts, title);
            var post   = config.Posts[index];

            Models.BlogModel model = new Models.BlogModel();
            model.BlogPost = GetBlogContent(post.Url);
            model.Title    = post.Title;

            if (config.Posts.Length <= index + 1)
            {
                model.Next = null;
            }
            //model.Next = "last";
            else
            {
                model.Next = "post?title=" + config.Posts[index + 1].Url;
            }

            if (index < 1)
            {
                model.Previous = null;
            }
            //model.Previous = "first";
            else
            {
                model.Previous = "post?title=" + config.Posts[index - 1].Url;
            }

            return(View(model));
        }
コード例 #2
0
 public void OnGet(int?id)
 {
     if (id != null)
     {
         DisplayPost = _context.Blogs.Where(m => m.BlogID == id).FirstOrDefault();
     }
 }