Exemplo n.º 1
0
        public async Task ProcessPageAsync(string page, object obj)
        {
            var document = new HtmlDocument();

            document.LoadHtml(page);

            var listA = document.DocumentNode.SelectNodes("//a[@class='decklist-name']");

            foreach (var deck in listA)
            {
                var name = deck.InnerText.FormatText();
                var url  = deck.Attributes["href"].Value;

                var deckModel = new StarWarsDestiny.Model.Deck
                {
                    InsertedIn = DateTime.Now,
                    Name       = name,
                    Url        = url
                };

                var deckOnDb = await _deckService.GetByNameAndUrl(name, url);

                if (deckOnDb == default)
                {
                    await _deckService.CreateAsync(deckModel);
                }
            }
        }