public async Task<ActionResult> Post(string id) { // XXX WORK HERE // Find the post with the given identifier var post = await _blogContext.Posts.Find(f => f.Id == id).SingleOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); // Find the post with the given identifier var post = await blogContext.Posts.Find<Post>(p => p.Id == ObjectId.Parse(id)).SingleOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); // XXX WORK HERE // Find the post with the given identifier var post = blogContext.Posts.Find(m => m.Id == id).FirstOrDefaultAsync().Result; if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); // XXX WORK HERE // Find the post with the given identifier var post = await blogContext.Posts.Find(Builders<Post>.Filter.Eq(x => x.Id, id)).FirstOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); var post = await blogContext.Posts.Find(x => x.Id == id).SingleOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post, NewComment = new NewCommentModel { PostId = id } }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); // XXX WORK HERE // Find the post with the given identifier IMongoCollection<Post> postsCollection = getPostsCollection(); var builder = Builders<Post>.Filter; FilterDefinition<Post> searchFilter = builder.Eq("_id", ObjectId.Parse(id)); Post post = await postsCollection.Find(searchFilter).FirstOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(String id) { var blogContext = new BlogContext(); // XXX WORK HERE // Find the post with the given identifier var post = await blogContext.Posts.Find(new BsonDocument("_id", new ObjectId(id))).FirstOrDefaultAsync(); if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }
public async Task<ActionResult> Post(string id) { var blogContext = new BlogContext(); // XXX WORK HERE // Find the post with the given identifier /* Response */ Post post = await blogContext.Posts.Find(p => p.Id == ObjectId.Parse(id)).SingleAsync(); /* ---- */ if (post == null) { return RedirectToAction("Index"); } var model = new PostModel { Post = post }; return View(model); }