//Index Action
        public ActionResult Index(string input, int id = 0)
        {
            //als nieuw: start game + zet id in session
            //else: haal id uit session en start op

            if (id == 0)
            {
                var gameId = Session["gameId"] as int?;
                if (!gameId.HasValue)
                {
                    return(RedirectToAction("FillDatabase"));
                }
                else
                {
                    story  = (Story)FindInDatabase("story", gameId.Value);
                    player = (Player)FindInDatabase("player", gameId.Value);
                    map    = (Map)FindInDatabase("map", gameId.Value);
                }
            }
            else
            {
                story  = (Story)FindInDatabase("story", id);
                player = (Player)FindInDatabase("player", id);
                map    = (Map)FindInDatabase("map", id);
            }

            if (input == null)
            {
                storyViewModel = new StoryViewModel(story, player);
                return(View(storyViewModel));
            }

            commandRepository = new CommandRepository(story, player);

            using (var context = ApplicationDbContext.Create())
            {
                context.Stories.Attach(story);
                context.Players.Attach(player);

                if (!player.InBattle)
                {
                    story.MyStory += commandRepository.GetCommandText(input);
                }
                else
                {
                    story.MyStory += commandRepository.GetBattleCommandText(input);
                }

                story.MyStory += commandRepository.ExecuteCommand(input);
                story.MyStory += commandRepository.EndOfAction();

                context.SaveChanges();
            }

            storyViewModel = new StoryViewModel(story, player);

            return(View(storyViewModel));
        }
        public ActionResult FillDatabase()
        {
            story  = new Story();
            map    = new Map();
            player = new Player();

            using (var context = ApplicationDbContext.Create())
            {
                context.Stories.Add(story);
                context.Maps.Add(map);
                context.Players.Add(player);

                map.BuildMap();

                commandRepository = new CommandRepository(story, player);
                commandRepository.CreatePlayer();
                story.MyStory += commandRepository.SpawnStory();

                context.SaveChanges();
            }
            Session.Add("gameId", story.Id);
            return(RedirectToAction("Index", new { id = story.Id }));
        }