예제 #1
0
        private int CalculateLoss(int roundId)
        {
            int sum       = 0;
            var roundComb = _roundRepository.GetById(roundId).WinningComination;
            var tickets   = _ticketRepository.GetTicketsByRound(roundId);

            foreach (var ticket in tickets)
            {
                var numberOfCorrectValues = _calculateCombination.GetNumberOfCorrectValues(ticket.Combination, roundComb);
                sum += _calculateCombination.CalculatePrize(numberOfCorrectValues);
            }
            return(sum);
        }
예제 #2
0
        public IEnumerable <TicketViewModel> GetTicketsByRoundId(int roundId)
        {
            var roundComb = _roundRepository.GetById(roundId).WinningComination;

            return(_ticketRepository.GetTicketsByRound(roundId).Select(t => new TicketViewModel
            {
                UserId = t.UserId,
                Combination = t.Combination,
                Status = t.Status,
                Round = t.Round,
                DateCreated = t.DateCreated,
                Prize = _calculateCombination.CalculatePrize(_calculateCombination
                                                             .GetNumberOfCorrectValues(t.Combination, roundComb))
            }));
        }