public FeedbackControllerTest()
        {
            _gebruikerRepository = new Mock <IGebruikerRepository>();
            _sessieRepository    = new Mock <ISessieRepository>();
            _controller          = new FeedBackController(_sessieRepository.Object, _gebruikerRepository.Object)
            {
                TempData = new Mock <ITempDataDictionary>().Object
            };

            _dummyData = new DummyData();
            // testdata ophalen
            testSessie    = _dummyData.s1;
            testGebruiker = _dummyData.piet;
            // testGebruiker inschrijven en aanwezig stellen
            testSessie.ToState(new RegistratieEnAanmeldenOpenState(testSessie));             // zorgen dat gebruiker kan inschrijven en aanmelden
            testGebruiker.SchrijfGebruikerInSessie(testSessie);
            testGebruiker.ZetAanwezigVoorSessie(testSessie);
            // schrijf een feedback
            testGebruiker.geefFeedbackOpSessie(testSessie, "een feedbackinhoud", 5);
        }
Exemplo n.º 2
0
        public IActionResult maakNieuweFeedbackEntry(Gebruiker gebruiker, int sessieId, string inhoud, int score)
        {
            if (inhoud == null || inhoud.Equals("") || score == null)
            {
                TempData["error"] = "Geen geldige invoer";
                return(RedirectToAction(nameof(Index), new { SessieId = sessieId }));
            }

            Sessie trackedSessie = _sessieRepository.GetById(sessieId);

            if (trackedSessie == null)
            {
                TempData["error"] = "De sessie bestaat niet";
                return(RedirectToAction(nameof(Index), new { SessieId = sessieId }));
            }

            Gebruiker trackedGebruiker = _gebruikerRepository.GetByGebruikersnaam(gebruiker.Gebruikersnaam);

            if (trackedGebruiker == null)
            {
                TempData["error"] = "De gebruiker bestaat niet";
                return(RedirectToAction(nameof(Index), new { SessieId = sessieId }));
            }

            try {
                trackedGebruiker.geefFeedbackOpSessie(trackedSessie, inhoud, score);
                _sessieRepository.SaveChanges();
            }
            catch (Exception e) {
                TempData["error"] = e.Message;
                return(RedirectToAction(nameof(Index), new { SessieId = sessieId }));
            }

            ViewData["gebruikerId"]       = gebruiker.Gebruikersnaam;
            ViewData["gebruikerINITIALS"] = gebruiker.GeefInitials();


            return(RedirectToAction(nameof(Index), new { SessieID = sessieId }));
        }