コード例 #1
0
ファイル: Create.cshtml.cs プロジェクト: demcy/BS_Original
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            NewGame ng = new NewGame(_context);

            Game.Player1.SelfBoard     = ng.DefaultBoard(false);//_context.Boards.FirstOrDefault(i => i.BoardId == b.BoardId);//b;
            Game.Player1.OppenentBoard = ng.DefaultBoard(true);
            Game.Player2.SelfBoard     = ng.DefaultBoard(false);
            Game.Player2.OppenentBoard = ng.DefaultBoard(true);
            _context.Games.Add(Game);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
 public void M1navigation(string c, int count, AppDbContext _context)
 {
     if (int.Parse(c) == count - 1)
     {
         Game Game = new Game();
         Game.GameName = "ConsoleGame";
         NewGame ng = new NewGame(_context);
         Game.Player1.SelfBoard     = ng.DefaultBoard(false);//_context.Boards.FirstOrDefault(i => i.BoardId == b.BoardId);//b;
         Game.Player1.OppenentBoard = ng.DefaultBoard(true);
         Game.Player2.SelfBoard     = ng.DefaultBoard(false);
         Game.Player2.OppenentBoard = ng.DefaultBoard(true);
         _context.Games.Add(Game);
         _context.SaveChangesAsync();
         DisplayM1();
     }
     else if (count == int.Parse(c))
     {
     }
     else
     {
         M2 m2 = new M2();
         m2.DisplayM2(Games[int.Parse(c) - 1].GameId, _context);
     }
 }