private void GetAuctionsDetailsFromPage(List <HtmlDocument> pages, List <AuctionDetails> auctionDetails)
        {
            foreach (var page in pages)
            {
                try
                {
                    foreach (var auction in page.DocumentNode.SelectNodes(".//*[@class='_00d6b80']"))
                    {
                        string title    = auction.SelectSingleNode(".//*[@class='_734e7e0']").FirstChild.ChildNodes[0].InnerText;
                        string url      = auction.SelectSingleNode(".//*[@class='_734e7e0']").FirstChild.FirstChild.GetAttributeValue("href", "title");
                        string price    = auction.SelectSingleNode(".//*[@class='fee8042']").ChildNodes[0].InnerText.Replace(" ", string.Empty);
                        string currency = auction.SelectSingleNode(".//span[@class='_31f32cc']")?.InnerText;
                        auctionDetails.Add(AuctionDetails.Create(url, title, price, currency));
                    }
                }
                catch (Exception ex)
                {
                    AuctionCounter--;
                    _logger.LogCritical(ex, "Error while downloading auction.");
                    continue;
                }

                AuctionCounter++;
            }

            _logger.LogInformation($"Downloaded progress auction : {AuctionCounter} / {pages.Count}");
        }
Esempio n. 2
0
        public ActionResult Create([FromBody] CreateAuctionDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var aggregateId   = Guid.NewGuid();
            var auction       = AuctionDetails.Create(DateTime.UtcNow.AddMinutes(1), dto.StartingPrice, dto.Description);
            var createAuction = CreateAuction.Create(auction);
            var command       = Command.Create(aggregateId, createAuction);
            var result        = _commandHandler.HandleCommand(command);

            switch (result)
            {
            case CommandResultSuccess _:
                return(Ok());

            default:
                return(Conflict());
            }
        }