public List <RaceBets> GetRaceDetails()
        {
            var result  = new List <RaceBets>();
            var races   = GetAll();
            var allBets = _betServices.GetAll().ToList();

            foreach (var race in races)
            {
                var raceDetails = new RaceBets {
                    Id = race.Id, Status = race.Status, Name = race.Name
                };
                raceDetails.Bets         = allBets.Where(x => x.RaceId == race.Id).ToList();
                raceDetails.RaceTotalBet = raceDetails.Bets.Sum(x => x.Stake);
                foreach (var horse in race.Horses)
                {
                    var thisRaceHorseBets = raceDetails.Bets.Where(x => x.HorseId == horse.Id).ToList();
                    var horseRace         = new HorseRace
                    {
                        Horse        = horse,
                        RaceId       = race.Id,
                        NumberOfBets = thisRaceHorseBets.Count,
                        TotalBet     = thisRaceHorseBets.Sum(x => x.Stake)
                    };

                    horseRace.OwingOnWin = horseRace.TotalBet * horseRace.Horse.Odds;
                    raceDetails.HorseRaces.Add(horseRace);
                }
                result.Add(raceDetails);
            }
            return(result);
        }
Esempio n. 2
0
        public IEnumerable <CustomerRisk> GetCustomerRiskReport()
        {
            var allCustomers = GetAll();

            return((from customer in allCustomers
                    let customerBets = _betBusinessServices.GetAll().Where(x => x.CustomerId == customer.Id)
                                       select new CustomerRisk
            {
                Customer = customer,
                BetAmount = customerBets.Sum(x => x.Stake),
                BetCount = customerBets.Count(),
                InHiRisk = customerBets.Sum(x => x.Stake) >= 200.00m
            }).ToList());
        }