コード例 #1
0
        public IActionResult DeleteBericht(int berichtId)
        {
            ForumLogic logic = new ForumLogic();

            logic.VerwijderBericht(berichtId);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task TopicTest()
        {
            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            string outputTopicName;

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                context.Topics.Add(dataSetA.Topic);
                context.SaveChanges();
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic       repoLogic       = new RepoLogic(context);
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);

                List <string> topicNames = (await forumController.GetTopics()).Value;
                outputTopicName = topicNames[0];
            }

            Assert.Equal(dataSetA.Topic.TopicName, outputTopicName);
        }
コード例 #3
0
        public IActionResult Index()
        {
            ForumViewModel viewModel = new ForumViewModel();
            ForumLogic     logic     = new ForumLogic();

            viewModel.Berichten = logic.AlleBerichten();
            return(View(viewModel));
        }
コード例 #4
0
        public IActionResult MaakReactie(BerichtViewModel viewModel, int BerichtId)
        {
            var logic = new ForumLogic();
            var model = new BerichtViewModel();

            model.Reactie.BerichtId      = BerichtId;
            model.Reactie.Gebruikersnaam = User.Identity.Name;
            model.Reactie.Tekstbericht   = viewModel.Reactie.Tekstbericht;
            model.Reactie.GebruikerId    = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value);
            logic.MaakReactie(model.Reactie);
            return(RedirectToAction("Bericht", new{ BerichtId }));
        }
コード例 #5
0
        public IActionResult Bericht(int BerichtId)
        {
            ForumLogic       logic = new ForumLogic();
            BerichtViewModel model = new BerichtViewModel();
            var bericht            = logic.BerichtMetId(BerichtId);

            model.BerichtId      = BerichtId;
            model.Titel          = bericht.BerichtTitel;
            model.Tekst          = bericht.Tekstbericht;
            model.Gebruikersnaam = bericht.Gebruikersnaam;
            model.Reacties       = logic.ReactiesVanBericht(BerichtId);
            return(View(model));
        }
コード例 #6
0
        public IActionResult MaakBericht(BerichtViewModel model)
        {
            Bericht bericht = new Bericht();

            bericht.Tekstbericht   = model.Tekst;
            bericht.BerichtTitel   = model.Titel;
            bericht.Gebruikersnaam = User.Identity.Name;
            bericht.GebruikerId    = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value);
            ForumLogic logic = new ForumLogic();

            logic.MaakBericht(bericht);

            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public async Task CommentsPageTest()
        {
            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            GlobalModels.Comment inputGMComment = BusinessLogic.Mapper.RepoCommentToComment(dataSetA.Comment);
            GlobalModels.Comment outputGMComment;

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var newComment = new GlobalModels.NewComment(inputGMComment);

                RepoLogic repoLogic = new RepoLogic(context);
                // Add Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                await repoLogic.AddDiscussion(dataSetA.Discussion, dataSetA.Topic);

                // Test CreateComment()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.CreateComment(newComment);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetComments()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.SetCommentsPageSize(10);

                List <GlobalModels.Comment> gmCommentList = (await forumController.GetCommentsPage(dataSetA.Comment.DiscussionId, 1)).Value;
                outputGMComment = gmCommentList
                                  .FirstOrDefault <GlobalModels.Comment>(c => c.Discussionid == dataSetA.Comment.DiscussionId);
            }

            Assert.Equal(inputGMComment, outputGMComment);
        }
コード例 #8
0
        public async Task GetDiscussionTest()
        {
            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            GlobalModels.Discussion inputGMDiscussion = BusinessLogic.Mapper.RepoDiscussionToDiscussion(dataSetA.Discussion, dataSetA.Topic);
            GlobalModels.Discussion outputGMDiscussion;

            // Seed the test database
            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var newDiscussion = new GlobalModels.NewDiscussion(inputGMDiscussion);

                RepoLogic repoLogic = new RepoLogic(context);
                // Add Database entries for the object-under-test's foreign keys
                await repoLogic.AddUser(dataSetA.User);

                await repoLogic.AddMovie(dataSetA.Movie.MovieId);

                await repoLogic.AddTopic(dataSetA.Topic);

                // Test CreateDiscussion()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                await forumController.CreateDiscussion(newDiscussion);
            }

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetDiscussions()
                IForumLogic     forumLogic      = new ForumLogic(repoLogic);
                ForumController forumController = new ForumController(forumLogic);
                outputGMDiscussion = (await forumController.GetDiscussion(dataSetA.Discussion.DiscussionId)).Value;
            }

            Assert.Equal(inputGMDiscussion, outputGMDiscussion);
        }