Пример #1
0
        public async Task <GetHistoryOfWins> GetHistoryOfWins(int gameId)
        {
            List <Round> rounds = await _roundRepository.GetAllRoundsByGameId(gameId);

            if (rounds == null)
            {
                var stringBuilder = new StringBuilder();

                stringBuilder.AppendLine(string.Format("GameId: {0}", gameId));
                stringBuilder.AppendLine(string.Format("Message: {0}", SolutionConstants.BUSINESS_LOGIC_GET_ITEM_EXCEPTION_MESSAGE));

                string message = stringBuilder.ToString();

                throw new BusinessLogicGetItemException(message);
            }

            var responseView = new GetHistoryOfWins();

            foreach (Round round in rounds)
            {
                SetHistoryOfWinsViewItem(responseView, round);
            }

            return(responseView);
        }
Пример #2
0
        private void SetHistoryOfWinsViewItem(GetHistoryOfWins responseView, Round round)
        {
            var viewItem = new GetHistoryOfWinsItem();

            viewItem.RoundNumber = round.NumberOfRound;

            foreach (Hand hand in round.Hands)
            {
                if (hand.Situation == Situation.Win)
                {
                    var viewItemItem = new GetHistoryOfWinsItemItem();

                    viewItemItem.NickName = hand.Player.NickName;
                    viewItemItem.Points   = hand.Summary;

                    viewItem.Players.Add(viewItemItem);
                }
            }

            responseView.Winners.Add(viewItem);
        }
Пример #3
0
        public async Task <GetHistoryOfWins> GetHistoryOfWins(int gameId)
        {
            GetHistoryOfWins getHistoryOfWins = await _gameLogicService.GetHistoryOfWins(gameId);

            return(getHistoryOfWins);
        }