public string Manage(MatchFeedModel feedModel, string tournamentId, string homeTeamId, string awayTeamId) { IEnumerable <int> keys = new List <int>() { feedModel.Key }; EntitiesByKeyQuery <Match> matchQuery = new EntitiesByKeyQuery <Match>(keys); Match match = queryDispatcher.Dispatch <EntitiesByKeyQuery <Match>, IEnumerable <Match> >(matchQuery).FirstOrDefault(); if (match != null) { UpdateMatchCommand updateCommand = Mapper.Map <UpdateMatchCommand>(feedModel); updateCommand.Id = match.Id; return(commandDispatcher.Dispatch <UpdateMatchCommand, string>(updateCommand)); } CreateMatchCommand createCommand = Mapper.Map <CreateMatchCommand>(feedModel); createCommand.TournamentId = tournamentId; createCommand.HomeTeamId = homeTeamId; createCommand.AwayTeamId = awayTeamId; return(commandDispatcher.Dispatch <CreateMatchCommand, string>(createCommand)); }
public MatchFeedModel Get(HtmlNode matchContainer) { HtmlNode matchInfo = matchContainer.SelectSingleNode(MatchXPaths.HEADER_INFO_BOX); MatchFeedType type = GetType(matchInfo); IEnumerable <TeamFeedModel> teams = teamsProvider.Get(matchContainer); TournamentFeedModel tournament = tournamentsProvider.Get(matchInfo); MatchFeedModel match = ObjectFactory.CreateMatch(type, teams.First(), teams.Last(), tournament); match.Markets = marketsProvider.Get(matchContainer, match); return(match); }
public void Manage(MatchFeedModel feedModel) { string tournamentId = tournamentsManager.Manage(feedModel.Tournament); string homeTeamId = teamsManager.Manage(feedModel.HomeTeam); string awayTeamId = teamsManager.Manage(feedModel.AwayTeam); string matchId = matchesManager.Manage(feedModel, tournamentId, homeTeamId, awayTeamId); foreach (var market in feedModel.Markets) { string marketId = marketsManager.Manage(market, matchId); oddsManager.Manage(market.Odds, marketId, matchId); } }
public IEnumerable <MarketFeedModel> Get(HtmlNode matchContainer, MatchFeedModel match) { ICollection <MarketFeedModel> markets = new List <MarketFeedModel>(); HtmlNodeCollection marketNodes = matchContainer.SelectNodes(MatchXPaths.MARKETS); foreach (var marketNode in marketNodes) { IList <string> oddNames = htmlService.GetOddNames(marketNode); MarketFeedModel market = ObjectFactory.CreateMarket(marketNode.FirstChild.FirstChild.InnerText, match.Key); market.Odds = oddsProvider.Get(marketNode, oddNames); markets.Add(market); } return(markets); }
public void Sync() { webPagesService.Load(webDriver, CommonConstants.FEED_URL, CommonConstants.WAIT_FOR_SCROLL_CONTAINER); webPagesService.ScrollToBottom(webDriver); ICollection <MatchFeedModel> processedFeed = new List <MatchFeedModel>(); IEnumerable <string> urls = htmlService.GetMatchUrls(MatchXPaths.EVENT_BODY, webDriver.PageSource); foreach (var url in urls) { bool isLoaded = webPagesService.Load(webDriver, url, CommonConstants.WAIT_FOR_MATCH_CONTAINER); if (isLoaded) { HtmlNode matchContainer = htmlService.GetMatchContainer(ContainerXPaths.MATCH, webDriver.PageSource); MatchFeedModel feedModel = matchesProvider.Get(matchContainer); feedManager.Manage(feedModel); processedFeed.Add(feedModel); } } unprocessedFeedManager.Manage(processedFeed); }