Skip to content

Instantly share code, notes, and snippets.

@maor365scores
Created June 8, 2022 12:32
Show Gist options
  • Save maor365scores/a817565ea04847f25185211eea063a49 to your computer and use it in GitHub Desktop.
Save maor365scores/a817565ea04847f25185211eea063a49 to your computer and use it in GitHub Desktop.
if (UpdateSequence >= lngMinUpdateID)
{
bGetAllGames = false;
// Get the games and notifications
List<CGameDTO> arrGames = GetGamesUpdates(arrUpdates, UpdateSequence, LangID, TimeZone, groupCategory,
Countries, Competitions, Competitors, Games, StartDateRange, EndDateRange, FullGameCenter,
UserCountry, WithExpandedColumns, filtersRelationOperator, withExpandedStats);
var sportTypeIds = arrGames.Select(g => g.SportTypeID).Distinct().ToArray();
if (sportTypeIds.Length == 1)
{
sportType = Sportifier.Competitions.BLL.General.SportTypes[sportTypeIds.Single()]
.SportType;
}
bool anyActiveStatusChange = false;
foreach (CGameDTO g in arrGames)
{
if (!onlyBets ||
Sportifier.Bets.BLL.General.Bookmakers.CheckIfGameHasValidBetLines(g.GameID,
UserCountry, platform, publisherID))
{
#region Update Bet Result
if (onlyBets)
{
IList<CBetLine> lines = Bets.BLL.General.BetLines
.GetLinesForGame(g.GameID, UserCountry, topBookmaker,
lastUpdateId: UpdateSequence, showNAOdds: showNAOdds, publisherID: publisherID)
.OrderBy(L => L.LineType).ToList();
if (lines != null)
{
CBetLine line = lines.FirstOrDefault();
if (line != null)
{
if (g.IsFinished)
{
if (line.ResultOption > 0)
{
g.BetResult = line.ResultOption;
}
}
}
}
}
else if (FullGameCenter)
{
// Get Best odds
try
{
sportType = Sportifier.Competitions.BLL.General.SportTypes[g.SportTypeID].SportType;
var viewContext = new ViewContext(EViewContext.BestOdds, platform,
g.GetViewTimeLine(), campaign, adgroup, layout, sportType);
var bestOdds = Bets.BLL.General.BetLines.GetBestLinesForGame(g.GameID,
UserCountry, topBookmaker, viewContext, showNAOdds, publisherID);
if (bestOdds != null &&
bestOdds.Any(line => line.UpdateSequence > UpdateSequence))
{
ViewContext[] extraViewContexts = null;
if (g.GetViewTimeLine() == EViewTimeLine.DuringGame)
{
extraViewContexts = new ViewContext[]
{
new ViewContext(EViewContext.OddsComparison, viewContext.Platform,
viewContext.TimeLine, campaign, adgroup, layout, sportType)
};
}
g.BestOdds = new CBetsResponseDTO()
{
Lines = bestOdds.Select(line => line.ToDTO(LangID, UserCountry,
viewContext: viewContext, extraViewContexts: extraViewContexts, publisherID: publisherID))
.ToArray(),
Bookmakers =
Bets.BLL.General.Bookmakers.GetEntities(
bestOdds.Select(line => line.Bookmaker.ID).Distinct())
.Select(bookmaker => bookmaker.ToDTO(LangID, viewContext,
UserCountry, extraViewContexts, publisherID))
.ToArray()
};
}
}
catch (Exception ex)
{
ExceptionsHandler.HandleException(ex);
}
}
if (withMainOdds)
{
try
{
sportType = Sportifier.Competitions.BLL.General.SportTypes[g.SportTypeID].SportType;
var viewContext = new ViewContext(EViewContext.DashboardMainOdds, platform,
g.GetViewTimeLine(), campaign, adgroup, layout, sportType);
var mainLine = Bets.BLL.General.BetLines.GetMainLineForGame(g.GameID,
g.SportTypeID, UserCountry, topBookmaker, viewContext, showNAOdds,
UpdateSequence, publisherID: publisherID);
if (mainLine != null)
{
var lineDTO = mainLine.ToDTO(LangID, UserCountry,
viewContext: viewContext, publisherID: publisherID);
g.MainOdds = lineDTO;
g.TopBookmaker = lineDTO.BookMakerID;
}
}
catch (Exception ex)
{
ExceptionsHandler.HandleException(ex);
}
}
#endregion
arrGamesList.Add(g);
if (g.IsFullDetailedGame)
{
if (!arrCompetitions.Exists(comp => comp.ID == g.CompetitionID))
{
arrCompetitions.Add(Sportifier.Competitions.BLL.General.Games[g.GameID]
.Competition.ToDTO(LangID, true, false, false, false, TimeZone));
}
}
if (g.ActiveChanged)
{
anyActiveStatusChange = true;
}
}
if (g.HasBets == true)
{
var sport = Sportifier.Competitions.BLL.General.SportTypes[g.SportTypeID];
sportType = sport.SportType;
AddOddsPreview(g, sport, platform, campaign, adgroup, layout, sportType, UserCountry, LangID,
showNAOdds, publisherID, OddsFormats);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment