public async Task <ResponseGetPlayersTwoCardsGameView> GetPlayersTwoCards(RequestGetPlayersTwoCardsGameView requestGetPlayersTwoCardsGameView) { Round round = await _roundRepository.Get(requestGetPlayersTwoCardsGameView.RoundId); Game game = await _gameRepository.GetGameWithPlayerGames(round.GameId); if (round == null || game == null) { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("RoundId: {0}", requestGetPlayersTwoCardsGameView.RoundId.ToString())); for (int i = 0; i < requestGetPlayersTwoCardsGameView.Players.Count; i++) { stringBuilder.AppendLine(string.Format("PlayerId: {0}", requestGetPlayersTwoCardsGameView.Players[i])); } stringBuilder.AppendLine(string.Format("Message: {0}", SolutionConstants.BUSINESS_LOGIC_GET_ITEM_EXCEPTION_MESSAGE)); string message = stringBuilder.ToString(); throw new BusinessLogicGetItemException(message); } await GiveOutTwoCards(game.Id, requestGetPlayersTwoCardsGameView); List <Hand> listHands = await _handRepository.GetListHandsWithCardsWithoutDeallerHandByRoundId(round.Id); if (listHands == null) { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("RoundId: {0}", round.Id)); stringBuilder.AppendLine(string.Format("Message: {0}", SolutionConstants.BUSINESS_LOGIC_GET_ITEM_EXCEPTION_MESSAGE)); string message = stringBuilder.ToString(); throw new BusinessLogicGetItemException(message); } var responseView = new ResponseGetPlayersTwoCardsGameView(); for (int i = 0; i < listHands.Count; i++) { List <Card> cards = listHands[i].HandCards.Select(item => item.Card).ToList(); var responseViewItem = new GetPlayersTwoCardsGameViewItem(); responseViewItem.PlayerId = listHands[i].PlayerId; responseViewItem.HandId = listHands[i].Id; responseViewItem.Cards = _mapper.Map <List <Card>, List <CardGetPlayersTwoCardsGameViewItemItem> >(cards); responseViewItem.Summary = listHands[i].Summary; responseView.ListPlayersWithCards.Add(responseViewItem); } return(responseView); }
public async Task <ResponseGetPlayersTwoCardsGameView> GetPlayersTwoCards([FromBody] RequestGetPlayersTwoCardsGameView requestGetPlayersTwoCardsGameView) { ResponseGetPlayersTwoCardsGameView responseGetPlayersTwoCardsGameView = await _gameLogicService.GetPlayersTwoCards(requestGetPlayersTwoCardsGameView); return(responseGetPlayersTwoCardsGameView); }