コード例 #1
0
 private void GetRunners()
 {
     if (SelectedRace != null)
     {
         if (SelectedRace.SelectedMarket != null)
         {
             var marketId = SelectedRace.SelectedMarket.MarketId;
             Console.WriteLine("Market {0} Selected", marketId);
             var marketCatalogue = service.GetMarketCatalogueForMarket(marketId, MarketProjection.RUNNER_METADATA);
             this.race = new MatchedBetRace();
             this.race.MarketId = marketId;
             this.race.MarketName = string.Format("{0} - {1}", selectedEvent.Name, selectedRace.RaceTitle);
             var runnerList = new ObservableCollection<MarketSelectorRunnerViewModel>();
             if (marketCatalogue.Any())
             {
                 foreach(var runner in marketCatalogue[0].Runners)
                 {
                     var runnerVM = new MatchedBetRunner()
                     {
                         SelectionId = runner.SelectionId,
                         RunnerName = runner.RunnerName,
                         SortPriority = runner.SortPriority,
                         ClothNumber = runner.Metadata.ContainsKey("CLOTH_NUMBER") ?
                                         runner.Metadata["CLOTH_NUMBER"] : "-"
                     };
                     race.Runners.Add(runnerVM);
                     runnerList.Add(new MarketSelectorRunnerViewModel(runnerVM));
                 }
             }
             this.Summary = new MarketSelectorSummaryViewModel(this.race.MarketName, runnerList);
             RaisePropertyChanged(() => ShowSummary);
         }
     }
 }
コード例 #2
0
        private void GetRaces()
        {
            var races = new ObservableCollection<MarketSelectorRaceViewModel>();
            if (SelectedEvent != null)
            {
                var catalogue = service.GetMarketCatalogueForEvent(this.selectedEvent.EventId).OrderBy(mc => mc.Description.MarketTime);

                DateTime? currentTime = null;
                MarketSelectorRaceViewModel race = null;
                foreach (var market in catalogue)
                {
                    if (currentTime == null || currentTime != market.Description.MarketTime)
                    {
                        race = new MarketSelectorRaceViewModel();
                        race.StartTime = market.Description.MarketTime;
                        races.Add(race);
                        currentTime = race.StartTime;
                    }

                    if (race != null && market.Description.MarketType == "WIN")
                    {
                        race.Distance = market.MarketName;

                        var raceMarket = new MarketSelectorMarketViewModel();
                        raceMarket.MarketId = market.MarketId;
                        raceMarket.MarketName = "Win";
                        race.Markets.Add(raceMarket);
                    }
                }
            }
            this.Races = races;
            this.SelectedRace = this.Races.Any() ? this.Races[0] : null;
            RaisePropertyChanged(() => ShowRaces);
        }