コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: apribeiro/M101N
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: AlyCrunch/HW_Week3
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: ax2015/testprojects
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }