コード例 #1
0
        public async Task <IActionResult> PostAttack([FromBody] StartAttackDto startAttackDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var userId = int.Parse(HttpContext.User.Identity.Name);
            await _armyService.AttackCity(userId, startAttackDto);

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> PostAttack(int playerId, [FromBody] StartAttackDto startAttackDto)
        {
            var player = await _playerService.GetPlayerAsync(playerId);

            if (player == null)
            {
                return(NotFound());
            }

            await _armyService.AttackCity(player.UserId, startAttackDto);

            return(Ok());
        }