示例#1
0
        public void DienActiesInMetActies()
        {
            _groep.CurrentState = new MotivatieGoedgekeurdState(_groep);
            _groep.AddContainer(new ActieContainer());
            _groep.VoegActieToe(new Actie("test", "actie"));
            _controller.DienActiesIn(_cursist);
            _groepRepository.Verify(g => g.SaveChanges(), Times.Once);


            Assert.Equal(typeof(ActieIngediendState), _groep.CurrentState.GetType());
        }
        public IActionResult VoegActieToe(Cursist cursist, ActieViewModel model)
        {
            Groep groep = cursist.Groep;

            if (ModelState.IsValid)
            {
                try
                {
                    var actie = new Actie(model.Titel, model.Omschrijving);
                    groep.VoegActieToe(actie);
                    _actieRepository.SaveChanges();
                    ViewBag._userMessage = $"Actie {actie.Titel} is succesvol toegevoegd";
                    return(ActieMaken(cursist));
                }
                catch (ArgumentException e)
                {
                    ViewBag._userError = e.Message;
                    return(ActieMaken(cursist));
                }
            }
            ViewBag._userError = "Gelieve alle velden correct in te vullen";
            return(ActieMaken(cursist));
        }
        public IActionResult VoegEvenementToe(Cursist cursist, EvenementViewModel model)
        {
            Groep groep = cursist.Groep;

            if (ModelState.IsValid)
            {
                try
                {
                    var evenement = new Actie(model.Titel, model.Omschrijving, model.Datum);
                    groep.VoegActieToe(evenement);
                    _cursistRepository.SaveChanges();
                    ViewBag._userMessage = $"Evenement {evenement.Titel} is succesvol aangemaakt";
                    return(ActieMaken(cursist));
                }
                catch (ArgumentException e)
                {
                    ViewBag._userError = e.Message;
                    return(ActieMaken(cursist));
                }
            }

            ViewBag._userError = "Gelieve alle velden correct in te vullen";
            return(ActieMaken(cursist));
        }
示例#4
0
        public ActieControllerTest()
        {
            _groepRepository     = new Mock <IGroepRepository>();
            _actieRepository     = new Mock <IActieRepository>();
            _cursistRepository   = new Mock <ICursistRepository>();
            _containerRepository = new Mock <IActieContainerRepository>();
            _berichtRepository   = new Mock <IBerichtRepository>();
            _controller          = new ActieController(_actieRepository.Object, _groepRepository.Object,
                                                       _cursistRepository.Object, _containerRepository.Object, _berichtRepository.Object);
            _cursist       = new Cursist("Fulvio", "Gentile", "*****@*****.**");
            _groep         = new Groep("G11", false);
            _cursist.Groep = _groep;
            _groep.VoegCursistToe(_cursist);

            _cursist2       = new Cursist("Robin", "Gammoudi", "*****@*****.**");
            _groep2         = new Groep("G12", false);
            _cursist2.Groep = _groep2;
            _groep2.VoegCursistToe(_cursist2);
            _groep2.CurrentState = new MotivatieGoedgekeurdState(_groep);
            _groep2.AddContainer(new ActieContainer());

            _groep2.VoegActieToe(new Actie("Testactie", "Testomschrijving"));
            _controller.DienActiesIn(_cursist2);
        }