// // GET: /Posts/ public ActionResult Index(int?Id) { int id = 0; if (Id != 0 && Id != null) { id = (int)Id; tbl_Post p = PostProvider.GetPost(id); List <tbl_Comment> c = CommentProvider.GetAllCommentByPostId(id); PostModel _PostModel = new PostModel { Id = p.Id, ContentMsg = p.ContentMsg, Title = p.Title, UpdatedBy = p.UpdatedBy }; List <CommentModel> _commentModel = (from temp in c select new CommentModel { Id = temp.Id, CommentText = temp.CommentText, PostId = temp.PostId, CommentedBy = temp.CommentedBy }).ToList(); PostViewModel Model = new PostViewModel(); Model.Comments = _commentModel; Model.Post = _PostModel; return(View(Model)); } else { return(View()); } }
public BlogPostModule(PostProvider provider) : base("/Posts") { Post["/{start:int}/{finish:int}"] = args => { IEnumerable <Post> posts = provider.GetPosts(args.start, args.finish); return(Negotiate.WithModel(posts).WithView("BlogPosts")); }; Post["/{PostName}"] = args => { Post model = provider.GetPost(args.PostName); return(Negotiate .WithModel(model) .WithView("FullPost") .WithHeader("blog-title", model.MetaData.Title)); }; Get["/{path}"] = args => { return(View["Views/Index.cshtml", (string)args.path]); }; }