public static IList <LineDTO> Convert(MarketCatalogue marketCatalogue, MarketBook marketBook, Action <LineDTO> action) { var lines = new List <LineDTO>(); foreach (var runner in marketBook.Runners) { decimal?сoeffParam; var coeffKind = GetCoeffKind(new GetCoeffKindParams(runner, marketCatalogue, runner.Handicap), out сoeffParam); if (string.IsNullOrEmpty(coeffKind)) { continue; } var coeffType = GetCoeffType(new GetCoeffKindParams(runner, marketCatalogue, runner.Handicap)); //берем меньший кэф var price = runner.ExchangePrices.AvailableToBack.OrderBy(x => x.Price).FirstOrDefault(x => x.Size > 100.0); if (price != null) { var line = new LineDTO { CoeffParam = сoeffParam, CoeffKind = coeffKind, CoeffValue = (decimal)price.Price, CoeffType = coeffType }; line.SerializeObject(new LineInfo { Size = price.Size, MarketId = marketBook.MarketId, SelectionId = runner.SelectionId, Handicap = runner.Handicap }); //line.LineData = string.Join(",", runner.ExchangePrices.AvailableToLay.Where(x => x.Size > 10.0).Select(f => (decimal)f.Price)); action(line); line.UpdateName(); lines.Add(line); } } return(lines); }
public static List <LineDTO> CreateLines(Market market, Dictionary <string, string> map, string coeffType = null) { var lines = new List <LineDTO>(); if (coeffType == "Match") { coeffType = null; } foreach (var selection in market.Selections.Where(x => map.ContainsKey(x.Name))) { var line = new LineDTO { Team1 = market.Event.Home, Team2 = market.Event.Away, Score1 = market.Event.Score1, Score2 = market.Event.Score2, Pscore1 = market.Event.Pscore1, Pscore2 = market.Event.Pscore2, EventDate = market.Event.EventDate.AddHours(3), CoeffValue = selection.Price.CoeffValue, CoeffKind = map[selection.Name], CoeffType = coeffType, Url = $"http://sports.whgaming.com/bet/ru/betting/e/{market.Event.Id}" }; if (selection.HcapInfo != null) { line.CoeffParam = selection.HcapInfo.HcapString.ToNullDecimal(); } line.SerializeObject(CreateSlipData(selection)); lines.Add(line); } return(lines); }