public List <LineDTO> GetLinesFromEvent(LineDTO template, EventFull @event) { var localLines = new List <LineDTO>(); var simpleMap = new Dictionary <string, string> { { template.Team1, "1" }, { template.Team2, "2" }, }; foreach (var offer in @event.BetOffers.Where(bo => !bo.suspended)) { var copy = template.Clone(); // Извлекаем тип игры: угловые, (желтые, красные карты), картер, и т.д. //if (!ConverterHelper.CheckCriterion(offer.criterion, out var period)) continue; foreach (var outcome in offer.outcomes) { if (outcome.status != "OPEN") { continue; } var line = copy.Clone(); switch (offer.betOfferType.englishName) { case "Match": switch (offer.criterion.englishLabel) { case "Full Time": case "1st Half": case "2nd Half": case "Half Time": case "Period 1": case "Period 2": case "Period 3": case "2nd Half (3-way)": case "Including Overtime": case "Quarter 1": case "Quarter 2": case "Quarter 3": case "Quarter 4": line.CoeffKind = outcome.englishLabel; break; case "Draw No Bet": case "Draw No Bet - 1st Half": case "Draw No Bet - 2nd Half": case "Draw No Bet - Regular Time": case "Draw No Bet - Quarter 1": case "Draw No Bet - Quarter 2": case "Draw No Bet - Quarter 3": case "Draw No Bet - Quarter 4": case "Draw No Bet - Period 1": case "Draw No Bet - Period 2": case "Draw No Bet - Period 3": line.CoeffKind = "W" + outcome.englishLabel; break; default: continue; } break; case "Handicap": case "Asian Handicap": if (offer.criterion.englishLabel == "Handicap" || offer.criterion.englishLabel == "Handicap - 1st Half" || offer.criterion.englishLabel == "Handicap - Quarter 1" || offer.criterion.englishLabel == "Handicap - Quarter 2" || offer.criterion.englishLabel == "Handicap - Quarter 3" || offer.criterion.englishLabel == "Handicap - Quarter 4" || offer.criterion.englishLabel == "Handicap - Including Overtime" || offer.criterion.englishLabel == "Handicap - Period 1" || offer.criterion.englishLabel == "Handicap - Period 2" || offer.criterion.englishLabel == "Handicap - Period 3" || offer.criterion.englishLabel == "Handicap - Regular Time") { line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel]; } else if (Regex.IsMatch(offer.criterion.englishLabel, "Asian Handicap \\([0-9] - [0-9]\\)")) { line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel]; } else { continue; } break; case "Over/Under": case "Asian Over/Under": switch (offer.criterion.englishLabel) { case "Total Points - 1st Half": case "Total Points - Quarter 1": case "Total Points - Quarter 2": case "Total Points - Quarter 3": case "Total Points - Quarter 4": case "Total Points - Including Overtime": case "Total Goals": case "Total Goals - 1st Half": case "Total Goals - Period 1": case "Total Goals - Period 2": case "Total Goals - Period 3": case "Total Goals - Regular Time": line.CoeffKind = "TOTAL" + outcome.englishLabel; break; case "Asian Total": case "Asian Total - 1st Half": line.CoeffKind = "TOTAL" + outcome.englishLabel; break; case "Total Goals by Away Team": case "Total Goals by Away Team - 1st Half": case "Total Goals by Away Team - 2nd Half": case "Total Goals by Away Team - Period 1": case "Total Goals by Away Team - Period 2": case "Total Goals by Away Team - Period 3": case "Total Goals by Away Team - Regular Time": line.CoeffKind = "ITOTAL" + outcome.englishLabel + "2"; break; case "Total Goals by Home Team": case "Total Goals by Home Team - 1st Half": case "Total Goals by Home Team - 2nd Half": case "Total Goals by Home Team - Period 1": case "Total Goals by Home Team - Period 2": case "Total Goals by Home Team - Period 3": case "Total Goals by Home Team - Regular Time": line.CoeffKind = "ITOTAL" + outcome.englishLabel + "1"; break; default: continue; } break; case "Double Chance": switch (offer.criterion.englishLabel) { case "Double Chance": case "Double Chance - Period 1": case "Double Chance - Period 2": case "Double Chance - Period 3": line.CoeffKind = outcome.englishLabel; break; default: continue; } break; case "Odd/Even": switch (offer.criterion.englishLabel) { case "Total Goals Odd/Even": case "Total Goals Odd/Even - 1st Half": case "Total Goals Odd/Even - 2nd Half": case "Total Points Odd/Even - Including Overtime": line.CoeffKind = outcome.englishLabel; break; default: continue; } break; default: continue; } //Параметр if (outcome.line != null) { line.CoeffParam = Math.Round(outcome.line.Value / 1000m, 2); } line.CoeffType = ConverterHelper.GetPeriod(offer.criterion.englishLabel); line.CoeffValue = Math.Round(outcome.odds / 1000m, 2); line.LineData = outcome.odds + ";" + outcome.id; line.LineObject = "| Outcome | " + JsonConvert.SerializeObject(outcome) + " | Offer | " + JsonConvert.SerializeObject(offer); line.UpdateName(); localLines.Add(line); } } return(localLines); }
public List <LineDTO> GetLinesFromEvent(LineDTO template, List <Market> markets) { var localLines = new List <LineDTO>(); foreach (var market in markets) { var copy = template.Clone(); var localGameType = string.Empty; // Извлекаем тип игры: угловые, (желтые, красные карты), картер, и т.д. if (string.IsNullOrEmpty(localGameType)) { localGameType = ConverterHelper.GetGameType(market.market_name); } if (!ConverterHelper.GetPeriod(market.result_type_name, out var period)) { continue; } copy.CoeffType = $"{period} {localGameType}"; if (!CheckExceptions(copy, market)) { continue; } foreach (var outcome in market.outcomes) { if (!outcome.outcome_visible) { continue; } var line = copy.Clone(); // Номер команды if (market.market_name.ContainsIgnoreCase("match winner", "1 X 2", "Double chance", "Odd / Even")) { line.CoeffKind = outcome.outcome_short_name; } else if (market.market_name.ContainsIgnoreCase("Draw No Bet")) { line.CoeffKind = $"W{outcome.outcome_short_name}"; } else if (market.market_name.ContainsIgnoreCase("Handicap")) { line.CoeffKind = $"HANDICAP{outcome.participant_number}"; } else if (market.market_name.ContainsIgnoreCase("Over/Under")) { line.CoeffKind = $"TOTAL{outcome.outcome_name.Split(" ")[0].ToUpper()}"; } else if (market.market_name.ContainsIgnoreCase("Team total")) { line.CoeffKind = $"ITOTAL{outcome.outcome_name.Split(" ")[0].ToUpper()}{outcome.participant_number}"; } else if (market.market_name.ContainsIgnoreCase("Odd / Even")) { line.CoeffKind = $"ITOTAL{outcome.outcome_name.Split(" ")[0].ToUpper()}{outcome.participant_number}"; } else { continue; } //Параметр if (decimal.TryParse(outcome.outcome_param, NumberStyles.Any, CultureInfo.InvariantCulture, out var param)) { line.CoeffParam = param; } line.CoeffValue = outcome.outcome_coef; line.LineData = new StoreBet { OutcomeId = outcome.outcome_id.ToLong(), EventId = market.event_id.ToLong(), MarketId = market.market_id.ToLong() }; line.UpdateName(); localLines.Add(line); } } return(localLines); }