Example #1
0
        private async Task ExploringStep(CancellationToken cancellationToken)
        {
            await RandomDelay(cancellationToken);

            var randomBook = await _booksRepository.GetRandomNotFilledBookAsync();

            await RandomDelay(cancellationToken);

            var bookExists = _seeker.ReadBookInfo(randomBook);

            if (!bookExists)
            {
                BookInfo.MarkAsNotFound(randomBook);
            }
            else
            {
                if (randomBook?.BookType == null)
                {
                    throw new InvalidOperationException(
                              "something went wrong, book properties was not read");
                }

                if (randomBook.ClosureDate.Length <= 4)
                {
                    var properties = _seeker.ReadProperties();
                    randomBook.AddNewProperties(properties);
                }
            }

            await _booksRepository.UpdateBookAsync(randomBook);

            await _booksRepository.AddPropertyFromBookAsync(randomBook);

            await RandomDelay(cancellationToken);

            _seeker.BackToCriteria();
        }