public async Task <IHttpActionResult> StartRound(StartRoundRequestViewModel startRoundRequestViewModel) { try { if (startRoundRequestViewModel == null) { return(BadRequest(GameMessageHelper.ReceivedDataError)); } string message = await _gameService.ValidateBet(startRoundRequestViewModel.Bet, startRoundRequestViewModel.GamePlayerId); if (string.IsNullOrEmpty(message)) { StartRoundResponseViewModel startRoundResponseViewModel = await _gameService.StartRound(startRoundRequestViewModel); return(Ok(new { Message = message, Data = startRoundResponseViewModel })); } return(Ok(new { Message = message })); } catch (Exception ex) { string message = $"{ex.Source}|{ex.TargetSite}|{ex.StackTrace}|{ex.Message}"; _logger.Error(message); return(BadRequest(GameMessageHelper.GameError)); } }
public async Task <StartRoundResponseViewModel> StartRound(StartRoundRequestViewModel startRoundRequestViewModel) { List <GamePlayer> players = (await _gamePlayerRepository.GetAllWithoutCards(startRoundRequestViewModel.GameId)).ToList(); _gamePlayerProvider.CreateBets(players, startRoundRequestViewModel.Bet); await DistributeFirstCards(players); _gamePlayerProvider.DefinePayCoefficientsAfterRoundStart(players); await _gamePlayerRepository.UpdateMany(players); await _gameRepository.UpdateStage(startRoundRequestViewModel.GameId, (int)GameStage.StartRound); List <Log> logs = LogHelper.GetStartRoundLogs(players, startRoundRequestViewModel.GameId); await _logRepository.CreateMany(logs, ToStringHelper.GetTableName(typeof(Log))); StartRoundResponseViewModel startRoundResponseViewModel = GetStartRoundResponse(players); return(startRoundResponseViewModel); }