/// <summary> /// Refreshes the items source. /// </summary> public override void RefreshData() { LoadKeyedCustomersData(); List <int> customers = KeyedCustomersData.Where(cb => cb.Value.Any(b => b.WinAmount > 0.6m * b.StakeAmount)).Select(c => c.Key).ToList(); Customers.Clear(); customers.ForEach(Customers.Add); SelectedCustomer = customers.FirstOrDefault(); }
/// <summary> /// Runs when selected customer is changed. /// </summary> protected override void OnSelectedCustomerChanged() { CustomerBets.Clear(); if (KeyedCustomersData.ContainsKey(SelectedCustomer)) { List <CustomerBet> unususalCustomerBets = KeyedCustomersData[SelectedCustomer].Where(b => b.WinAmount > 0.6m * b.StakeAmount).ToList(); unususalCustomerBets.ForEach(CustomerBets.Add); } }
/// <summary> /// Runs when selected customer is changed. /// </summary> protected override void OnSelectedCustomerChanged() { CustomerBets.Clear(); if (KeyedCustomersData.ContainsKey(SelectedCustomer)) { List <CustomerBet> customerItems = KeyedCustomersData[SelectedCustomer]; var average = customerItems.Sum(i => i.StakeAmount) / customerItems.Count; customerItems.ForEach(cb => { if (cb.WinAmount > 0.6m * cb.StakeAmount) { cb.RiskyUnsettledBetSeverity = RiskSeverity.Risky; } if (cb.StakeAmount > 10 * average) { cb.RiskyUnsettledBetSeverity = RiskSeverity.Unusual; } if (cb.StakeAmount > 30 * average) { cb.RiskyUnsettledBetSeverity = RiskSeverity.HighlyUnusual; } if (cb.WinAmount >= 1000m) { cb.RiskyUnsettledBetSeverity = RiskSeverity.HighWonAmount; } }); List <CustomerBet> riskyCustomerBets = (from cb in customerItems where cb.WinAmount > 0.6m * cb.StakeAmount || cb.StakeAmount > 10 * average || cb.StakeAmount > 30 * average || cb.WinAmount >= 1000m select cb).ToList(); riskyCustomerBets.ForEach(CustomerBets.Add); } }