public async Task <ActionResult> AddPlayerToGame([FromBody] PlayerToGameVM playerDTO) { if (await _gameService.AddPlayerToGame(playerDTO)) { return(Ok()); } return(BadRequest()); }
//todo: from here should come the signal to refresh Player's Stats next time it's needed public async Task <bool> AddPlayerToGame(PlayerToGameVM PlayerGameDTO) { var _player = await GetPlayer(PlayerGameDTO.PlayerId); var _game = await GetGame(PlayerGameDTO.GameId); if (PlayerOrGameMissing(_player, _game)) { return(false); } else { await AddPlayerGame(PlayerGameDTO); return(true); } }
private async Task AddPlayerGame(PlayerToGameVM PlayerGameDTO) { await _gameRepo.AddPlayerGame( new PlayerGame(PlayerGameDTO.PlayerId, PlayerGameDTO.GameId, PlayerGameDTO.TeamB) ); }