public ActionResult ViewPost(Guid id) { var post = DataAccessLayer.GetById<BlogPost>(id); if (post == null) { return HttpNotFound("Post not found"); } var blogEntry = new Blog.Entry(); blogEntry.Title = post.Title; blogEntry.FullText = post.FullText; blogEntry.CreatedDate = post.CreationDate; blogEntry.ModifyDate = post.ModifyDate; return View(blogEntry); }
public ActionResult Posts() { //TODO: get list of blogs by UserId //Guid id = new Guid("428efc0e-27a8-4cf7-a036-88228253a2cd"); var listOfPosts = DataAccessLayer.TopRandom<BlogPost>(200); if (listOfPosts == null) { return HttpNotFound("Posts not found"); } var posts = new List<Blog.Entry>(); foreach (var blogPost in listOfPosts) { var post = new Blog.Entry(); post.CreatedDate = blogPost.CreationDate; post.FullText = blogPost.FullText; post.Title = blogPost.Title; post.Id = blogPost.Id; posts.Add(post); } return View(posts); }
public ActionResult Detail(Guid id) { var post = DataAccessLayer.GetById<BlogPost>(id); if (post == null) { return HttpNotFound("Post not found"); } var binder = new BlogToBlogPost(DataAccessLayer); var entry = new Blog.Entry(); binder.InverseLoad(post, entry); return View(entry); }
public ActionResult TopPosts() { //var listOfPosts = DataAccessLayer.TopRandom<BlogPost>(BlogsCount); var listOfPosts = DataAccessLayer.Get<BlogPost>().Take(BlogsCount); if (listOfPosts == null) { return HttpNotFound("Posts not found"); } var blog = new Blog {Posts = new List<Blog.Entry>()}; foreach (var blogPost in listOfPosts) { var binder = new BlogToBlogPost(DataAccessLayer); var entry = new Blog.Entry(); binder.InverseLoad(blogPost, entry); blog.Posts.Add(entry); } return PartialView(blog); }