コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: OddsManager.cs プロジェクト: itplamen/SportsBetting
        public void Manage(IEnumerable <OddFeedModel> feedModels, string marketId, string matchId)
        {
            foreach (var feedModel in feedModels)
            {
                IEnumerable <int> keys = new List <int>()
                {
                    feedModel.Key
                };
                EntitiesByKeyQuery <Odd> query = new EntitiesByKeyQuery <Odd>(keys);
                Odd odd = queryDispatcher.Dispatch <EntitiesByKeyQuery <Odd>, IEnumerable <Odd> >(query).FirstOrDefault();

                if (odd != null)
                {
                    UpdateOddCommand updateCommand = Mapper.Map <UpdateOddCommand>(feedModel);
                    updateCommand.Id = odd.Id;

                    commandDispatcher.Dispatch <UpdateOddCommand, string>(updateCommand);
                }
                else
                {
                    CreateOddCommand createCommand = Mapper.Map <CreateOddCommand>(feedModel);
                    createCommand.IsActive = true;
                    createCommand.MatchId  = matchId;
                    createCommand.MarketId = marketId;

                    commandDispatcher.Dispatch <CreateOddCommand, string>(createCommand);
                }
            }
        }
コード例 #3
0
        public string Manage(TeamFeedModel feedModel)
        {
            IEnumerable <int> teamKeys = new List <int>()
            {
                feedModel.Key
            };
            EntitiesByKeyQuery <Team> teamQuery = new EntitiesByKeyQuery <Team>(teamKeys);
            Team team = queryDispatcher.Dispatch <EntitiesByKeyQuery <Team>, IEnumerable <Team> >(teamQuery).FirstOrDefault();

            if (team != null)
            {
                return(team.Id);
            }

            IEnumerable <int> sportKeys = new List <int>()
            {
                CommonConstants.ESPORT_KEY
            };
            EntitiesByKeyQuery <Sport> sportQuery = new EntitiesByKeyQuery <Sport>(sportKeys);
            Sport sport = queryDispatcher.Dispatch <EntitiesByKeyQuery <Sport>, IEnumerable <Sport> >(sportQuery).First();

            CreateTeamCommand teamCommand = Mapper.Map <CreateTeamCommand>(feedModel);

            teamCommand.SportId = sport.Id;

            return(commandDispatcher.Dispatch <CreateTeamCommand, string>(teamCommand));
        }
コード例 #4
0
        public IEnumerable <TEntity> Handle(EntitiesByKeyQuery <TEntity> query)
        {
            if (query.Expression == null)
            {
                return(cache.All(x => query.Keys.Contains(x.Key)));
            }

            return(cache.All(query.Expression));
        }
コード例 #5
0
        private void DeleteUnprocessedEntities <TEntity>(IEnumerable <int> entityKeys)
            where TEntity : BaseModel
        {
            EntitiesByKeyQuery <TEntity> entitiesQuery = new EntitiesByKeyQuery <TEntity>(entityKeys, x => !entityKeys.Contains(x.Key));
            IEnumerable <TEntity>        entities      = queryDispatcher.Dispatch <EntitiesByKeyQuery <TEntity>, IEnumerable <TEntity> >(entitiesQuery);

            DeleteEntitiesCommand <TEntity> entitiesCommand = new DeleteEntitiesCommand <TEntity>(entities);

            commandDispatcher.Dispatch(entitiesCommand);
        }
コード例 #6
0
        public string Manage(MarketFeedModel feedModel, string matchId)
        {
            IEnumerable <int> keys = new List <int>()
            {
                feedModel.Key
            };
            EntitiesByKeyQuery <Market> query = new EntitiesByKeyQuery <Market>(keys);
            Market market = queryDispatcher.Dispatch <EntitiesByKeyQuery <Market>, IEnumerable <Market> >(query).FirstOrDefault();

            if (market != null)
            {
                return(market.Id);
            }

            CreateMarketCommand command = Mapper.Map <CreateMarketCommand>(feedModel);

            command.MatchId = matchId;

            return(commandDispatcher.Dispatch <CreateMarketCommand, string>(command));
        }