Ejemplo n.º 1
0
 public IActionResult ZetGroepInSpel(Sessie sessie, string groepid)
 {
     try
     {
         Groep groep = sessie.Groepen.FirstOrDefault(g => g.GroepId == Int32.Parse(groepid));
         groep.ZetInSpel();
         _sessieRepository.SaveChanges();
         TempData["success"] = $"Groep #{groep.GroepId} zit nu in het spel.";
     }
     catch (StateException e)
     {
         TempData["warning"] = e;
     }
     catch (Exception e)
     {
         TempData["warning"] = e;
     }
     return(RedirectToAction(nameof(SessieBeheren)));
 }
Ejemplo n.º 2
0
        public IActionResult StartSpel(Sessie sessie, Groep groep)
        {
            if (groep != null)
            {
                try
                {
                    if (sessie.CurrentState is SessieGeblokkeerdState == false)
                    {
                        if (groep.CurrentState is GroepGekozenState)
                        {
                            groep.ZetInSpel();
                        }
                        groep.StartVolgendeOpdracht();
                        _sessieRepository.SaveChanges();

                        return(RedirectToAction(nameof(SpelController.SpelSpelen), "Spel"));
                    }
                    else
                    {
                        TempData["info"] = $"Deze sessie is momenteel geblokkeerd.";
                    }
                }
                catch (StateException e)
                {
                    TempData["warning"] = e;
                }
                catch (Exception e)
                {
                    TempData["warning"] = e;
                }
            }
            else
            {
                TempData["warning"] = $"Je hebt geen groep gekozen. Je kunt het spel niet spelen zonder groep.";
            }
            return(RedirectToAction(nameof(GroepKiezen)));
        }