コード例 #1
0
        private PostReplyService CreateReplyService()
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new PostReplyService(userID);

            return(service);
        }
コード例 #2
0
        // GET: /PostReply
        public ActionResult Index()
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new PostReplyService(userID);
            var model   = service.GetAllReplies();

            return(View(model));
        }
コード例 #3
0
        public ActionResult RedirectToPostRepliesIndex(int replyID)
        {
            var service = new PostReplyService();
            var entity  = service.GetReplyByID(replyID);
            int postID  = entity.PostID;

            return(RedirectToAction("PostRepliesIndex", new { postID }));
        }
コード例 #4
0
        // GET: /PostReply/PostRepliesIndex
        public ActionResult PostRepliesIndex(int postID)
        {
            var service = new PostReplyService();
            var model   = service.GetRepliesByPostID(postID);

            ViewData["postID"] = postID;

            return(View(model));
        }
コード例 #5
0
        //public ActionResult RedirectToPostRepliesIndex(int replyID)
        //{
        //    var service = new PostReplyService();
        //    var entity = service.GetReplyByID(replyID);
        //    int postID = entity.PostID;

        //    return RedirectToAction("PostRepliesIndex", new { postID });
        //}

        // GET: /PostReply/PostRepliesIndex
        public ActionResult PostRepliesIndex(int postID)
        {
            var service     = new PostReplyService();
            var model       = service.GetRepliesByPostID(postID);
            var newService  = new PostService();
            var parent      = newService.GetPostByID(postID);
            var postContent = parent.PostContent;

            ViewData["postContent"] = postContent;
            ViewData["postID"]      = postID;
            return(View(model));
        }
コード例 #6
0
        public void Filtered_Posts_Returns_Correct_Result_Count()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "Search_Database").Options;

            using (var ctx = new ApplicationDbContext(options))
            {
                ctx.Forums.Add(new Data.Models.Forum()
                {
                    Id = 19
                });

                ctx.Posts.Add(new Post
                {
                    Forum   = ctx.Forums.Find(19),
                    Id      = 21341,
                    Title   = "Functional programming",
                    Content = "Does anyone have experience deploying Haskell to production?"
                });

                ctx.Posts.Add(new Post
                {
                    Forum   = ctx.Forums.Find(19),
                    Id      = -324,
                    Title   = "Haskell Tail Recursion",
                    Content = "Haskell Haskell"
                });

                ctx.SaveChanges();
            }

            using (var ctx = new ApplicationDbContext(options))
            {
                var postService      = new PostService(ctx);
                var postReplyService = new PostReplyService(ctx);
                var forumService     = new ForumService(ctx, postService, postReplyService);
                var postCount        = forumService.GetFilteredPosts(19, "Haskell").Count();
                Assert.AreEqual(2, postCount);
            }
        }