public void Handle(BetPlaced placedEvent) { var reportRepository = _reportRepositoryFactory(); var record = reportRepository.PlayerBetHistoryRecords.SingleOrDefault(r => r.GameActionId == placedEvent.GameActionId); if (record != null) { throw new RegoException(string.Format("Player bet history record {0} already exists", placedEvent.RoundId)); } record = reportRepository.PlayerBetHistoryRecords.SingleOrDefault(r => r.RoundId == placedEvent.RoundId); if (record != null) { record.BetAmount += placedEvent.Amount; record.TotalWinLoss -= placedEvent.Amount; reportRepository.SaveChanges(); return; } var brand = _brandQueriesFactory().GetBrandOrNull(placedEvent.BrandId); var player = _playerQueriesFactory().GetPlayer(placedEvent.PlayerId); var game = _gameQueriesFactory().GetGameDtos().SingleOrDefault(g => g.Id == placedEvent.GameId); record = new PlayerBetHistoryRecord { GameActionId = placedEvent.GameActionId, RoundId = placedEvent.RoundId, Brand = brand != null ? brand.Name : null, Licensee = brand != null && brand.Licensee != null ? brand.Licensee.Name : null, Currency = player != null ? player.CurrencyCode : null, GameName = game != null ? game.Name : null, LoginName = player != null ? player.Username : null, UserIP = player != null ? player.IpAddress ?? "127.0.0.1" : null, DateBet = placedEvent.CreatedOn, BetAmount = placedEvent.Amount, TotalWinLoss = -placedEvent.Amount }; reportRepository.PlayerBetHistoryRecords.Add(record); reportRepository.SaveChanges(); }
public ActionResult ExportPlayerBetHistoryReport(PlayerBetHistoryRecord filters, string sortColumnName, string sortOrder, string hiddenColumns = null) { return(ExportReport(_queries.GetPlayerBetHistoryRecordsForExport(), filters, sortColumnName, sortOrder, hiddenColumns)); }