コード例 #1
0
        public void Handle(PlayerYearAdded theEvent)
        {
            //add this to Solr
            var hitter = new Hitter()
            {
                Average      = theEvent.Average,
                Doubles      = theEvent.Doubles,
                FirstName    = theEvent.FirstName,
                Hits         = theEvent.Hits,
                HomeRuns     = theEvent.HomeRuns,
                Id           = String.Format("{0}_{1}", theEvent.Id.ToString(), theEvent.Year.ToString()),
                LahmanId     = theEvent.Id,
                LastName     = theEvent.LastName,
                PlayerId     = theEvent.PlayerId,
                RunsBattedIn = theEvent.RunsBattedIn,
                Salary       = theEvent.Salary,
                StrikeOuts   = theEvent.StrikeOuts,
                TeamName     = theEvent.Team,
                Triples      = theEvent.Triples,
                Year         = theEvent.Year
            };
            var search = SearchFactory.GetSearchService();

            search.AddHitter(hitter);
        }
コード例 #2
0
ファイル: SearchControllers.cs プロジェクト: ray923/Demos
        public IActionResult GetHitResults([FromBody] SearchCondition condition)
        {
            if (string.IsNullOrEmpty(_engineList))
            {
                return(BadRequest("No search engine"));
            }
            var engingList   = _engineList.Split(",");
            var totalResults = new List <HitResultsView>();

            if (string.IsNullOrEmpty(condition.SearchUrl))
            {
                return(Ok(totalResults));
            }

            foreach (var engine in engingList)
            {
                // Simple Factory pattern to create the search enginge services
                var service = SearchFactory.GetSearchService(engine);
                if (service != null)
                {
                    var searchResults  = service.GetSearchResults(condition.SearchKeyword);
                    var hitResults     = service.GetHitResults(condition.SearchUrl, searchResults);
                    var HitResultsView = new HitResultsView()
                    {
                        SearchEngineName = engine,
                        ResultList       = hitResults
                    };
                    totalResults.Add(HitResultsView);
                }
            }
            ;
            return(Ok(totalResults));
        }