Ejemplo n.º 1
0
		public async Task<IHttpActionResult> StartHumanGame(StartHumanGameDTO body)
		{
			var enemyName = body.name;
			var enemy = _repo.FindUser(enemyName);
			if (enemy == null)
			{
				return NotFound();
			}
			var me = _repo.FindUser(User.Identity.GetUserName());

			var game = new Game { Human1 = me, Human2 = enemy };
			game.SetUpInitialPosition();
			_ctx.Games.Add(game);
			await _ctx.SaveChangesAsync();

			return Ok(); // todo, return id of new game to auto-highlight it in subsequent /games screen
		}
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> StartHumanGame(StartHumanGameDTO body)
        {
            var enemyName = body.name;
            var enemy     = _repo.FindUser(enemyName);

            if (enemy == null)
            {
                return(NotFound());
            }
            var me = _repo.FindUser(User.Identity.GetUserName());

            var game = new Game {
                Human1 = me, Human2 = enemy
            };

            game.SetUpInitialPosition();
            _ctx.Games.Add(game);
            await _ctx.SaveChangesAsync();

            return(Ok());            // todo, return id of new game to auto-highlight it in subsequent /games screen
        }