Exemplo n.º 1
0
        private void AssignTexboxesKomplett(string rawHtml)
        {
            var kScraper = new KomplettScraper();

            if (kScraper.FetchKomplettTitle(rawHtml) != string.Empty ||
                kScraper.FetchKomplettPNumber(rawHtml) != string.Empty ||
                kScraper.FetchKomplettPrice(rawHtml) != string.Empty ||
                kScraper.FetchKomplettStockStatus(rawHtml) != string.Empty)
            {
                try
                {
                    _addedProduct.pPrice = CheckPrice.CheckPriceFormat(kScraper.FetchKomplettPrice(rawHtml));
                }
                catch (FormatException)
                {
                    MessageBox.Show("Please provide a price containing only numbers and a single dot.",
                                    "Price contains letters.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (OverflowException)
                {
                    MessageBox.Show("The price is too high.", "Price too high.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (PriceTooLongException)
                {
                    MessageBox.Show("The price is too long.", "Price too long.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                catch (PriceContainsCommaException)
                {
                    MessageBox.Show("Please use a dot instead of comma in the product price.", "Price contains comma.",
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                    _addedProduct.pPrice = 0.00;
                }
                _addedProduct.pName        = kScraper.FetchKomplettTitle(rawHtml);
                _addedProduct.pNumber      = kScraper.FetchKomplettPNumber(rawHtml);
                _addedProduct.PStockStatus = kScraper.FetchKomplettStockStatus(rawHtml);
                _addedProduct.pType        =
                    (Product.ProductType)
                    Enum.Parse(typeof(Product.ProductType),
                               kScraper.KomplettPTypeMapping(kScraper.FetchKomplettPType(AddProductUrlTextBox.Text)));
            }
            else
            {
                MessageBox.Show("No product found at the given URL.");
            }
        }
Exemplo n.º 2
0
        private void AssignTexboxesKomplett(string rawHtml)
        {
            var kScraper = new KomplettScraper();

            if (kScraper.FetchKomplettTitle(rawHtml) != string.Empty ||
                kScraper.FetchKomplettPNumber(rawHtml) != string.Empty ||
                kScraper.FetchKomplettPrice(rawHtml) != string.Empty ||
                kScraper.FetchKomplettStockStatus(rawHtml) != string.Empty)
            {
                PNameTxtBox.Text           = kScraper.FetchKomplettTitle(rawHtml);
                PNumberTxtBox.Text         = kScraper.FetchKomplettPNumber(rawHtml);
                PPriceTxtBox.Text          = kScraper.FetchKomplettPrice(rawHtml);
                PStockStatus.Text          = kScraper.FetchKomplettStockStatus(rawHtml);
                PTypeCombobox.SelectedItem =
                    (Product.ProductType)
                    Enum.Parse(typeof(Product.ProductType),
                               kScraper.KomplettPTypeMapping(kScraper.FetchKomplettPType(PUrlTxtBox.Text)));
            }
            else
            {
                MessageBox.Show("No product found at the given URL.");
            }
        }