Ejemplo n.º 1
0
 //Start - GET
 public IActionResult Start(int?id)
 {
     Madlib.Models.Madlib obj = _db.Madlib.Find(id);
     if (obj == null)
     {
         return(NotFound());
     }
     else
     {
         return(View(obj));
     }
 }
Ejemplo n.º 2
0
 //GET - DISPLAYRESULTS
 public IActionResult DisplayResults(SinglePlayerGame game)
 {
     if (game == null)
     {
         return(NotFound());
     }
     Madlib.Models.Madlib madLib  = _db.Madlib.Find(game.MadlibId);
     string[]             Answers = _db.SinglePlayerGameFilledBlank.Where(b => b.SinglePlayerGameId == game.Id).OrderBy(b => b.MadlibBlankIndex).Select(b => b.Answer).ToArray();
     game.Madlib         = madLib;
     game.CompletedStory = string.Format(madLib.Text, Answers);
     return(View(game));
 }
Ejemplo n.º 3
0
        public IActionResult Start(Madlib.Models.Madlib obj)
        {
            if (obj == null)
            {
                return(NotFound());
            }
            SinglePlayerGame NewGame = new SinglePlayerGame()
            {
                MadlibId = obj.Id,
                ActiveMadlibBlankIndex = 0
            };

            if (ModelState.IsValid)
            {
                _db.SinglePlayerGame.Add(NewGame);
                _db.SaveChanges();
                SinglePlayerGameFilledBlank nextBlank = AddNextBlankToAnswers(NewGame);
                return(RedirectToAction("Play", nextBlank));
            }
            else
            {
                return(View(obj));
            }
        }