public void Run()
        {
            _logger.LogInformation("Application started.");

            var newsItems = _reader.Read();

            _indexer.Index(newsItems);

            _logger.LogInformation("Application ended.");
        }
Exemple #2
0
        public async Task <ActionResult> Index()
        {
            var teams = await _teamRepository.GetAll();

            await _indexer.DeleteIndex("team");

            await _indexer.Index(teams);

            return(Ok());
        }
        private void HandleTaskAdded(dynamic data, dynamic metaData)
        {
            DateTime?dueDate = null;

            if (data.DueDate.Value != null)
            {
                if (DateTime.TryParse(data.DueDate.Value.ToString(), out DateTime dueDateVal))
                {
                    dueDate = dueDateVal;
                }
            }

            var zeroTask = new ZeroTask(data.Id.Value, metaData.username.Value, data.Title.Value, data.Description.Value, dueDate,
                                        ((Priority)data.Priority.Value).ToString(), metaData.source.Value, metaData["$correlationId"].Value, metaData["applies"].Value);

            _indexer.Index(zeroTask);
        }
        public async Task <ActionResult> Index()
        {
            try
            {
                var players = (await _playerRepository.GetAll()).ToList();

                if (!players.Any())
                {
                    return(NotFound("No players to index."));
                }

                await _indexer.DeleteIndex("players");

                await _indexer.Index(players);

                return(Ok($"{players.Count} players indexed."));
            }
            catch (Exception ex)
            {
                return(BadRequest($"Error indexing players: {ex}"));
            }
        }
Exemple #5
0
        public SearchEngine(List <Shirt> shirts)
        {
            if (shirts == null)
            {
                throw new ArgumentNullException("Parameters 'shirts' cannot be null");
            }

            if (!shirts.Any())
            {
                throw new ArgumentException("Number of shirts must be greater than 0");
            }

            //We shall keep a dictionary of shirts (so we can look up shirts by ID)
            _shirts = shirts.ToDictionary(s => s.Id, s => s);

            // TODO: data preparation and initialisation of additional data structures to improve performance goes here.
            _indexer = new Indexer();

            //Convert shirts to documents and index
            _shirts.Values.ToList().ForEach(shirt =>
            {
                _indexer.Index(ToIndexDocument(shirt));
            });
        }
Exemple #6
0
        public void GetDocumentById()
        {
            //Arrange
            var document = _fixture.Create <IndexDocument>();

            //Act
            _sut.Index(document);

            //Assert
            var retrievedDocument = _sut.GetDocument(document.Id);

            Assert.AreEqual(document, retrievedDocument);
        }