public async Task <IList <Race> > GetRaces() { var races = await _apiClient.GetRaces(); var bets = await _apiClient.GetBets(); return(races.Select(r => { var raceBets = bets.Where(b => b.RaceId == r.Id).ToList(); return new Race { Id = r.Id, Status = r.Status, TotalAmount = raceBets.Sum(b => b.Stake), Horses = r.Horses.Select(h => { var horseBets = raceBets.Where(b => b.HorseId == h.Id).ToList(); return new Horse { Id = h.Id, Name = h.Name, TotalBets = horseBets.Count, TotalPayout = horseBets.Sum(b => b.Stake) * h.Odds }; }).ToList() }; }).ToList()); }
public async Task <CustomerList> GetCustomers() { var customers = await _apiClient.GetCustomers(); var bets = await _apiClient.GetBets(); return(new CustomerList { TotalAmountBet = bets.Sum(b => b.Stake), Customers = customers.Select(c => { var customerBets = bets.Where(b => b.CustomerId == c.Id).ToList(); return new Customer { Id = c.Id, TotalBets = customerBets.Count, TotalAmountBet = customerBets.Sum(b => b.Stake), IsRisky = customerBets.Any(b => b.Stake > _riskThreshold) }; }).ToList() }); }
public async Task CanGetBets() { var bets = await _apiClient.GetBets(); Assert.IsTrue(bets.Any()); }