public async Task TestUpdatePost() { // Create a post ArticleRoot post = new ArticleRoot { Article = new Article { Active = false, ArticleNumber = "TEST-58878", Description = "Updated Testing" } }; // Update the post FortnoxResponse<ArticleRoot> fr = await config.fortnox_client.Update<ArticleRoot>(post, "articles/TEST-58878"); // Log the error if (fr.model == null) { config.logger.LogError(fr.error); } // Test evaluation Assert.AreNotEqual(null, fr.model); } // End of the TestUpdatePost method
public List <Article> SelectNewsByKeyword(string keyword) { List <Article> articleList = null; HttpClient client = GetClient(); HttpResponseMessage response = client.GetAsync($"/v2/everything?q={keyword}&apiKey={apiKey}&language=de").Result; if (response.IsSuccessStatusCode) { ArticleRoot root = response.Content.ReadAsAsync <ArticleRoot>().Result; articleList = root.Articles; } return(articleList.Take(5).ToList()); }
public List <Article> SelectNewsBySource(string source) { List <Article> articleList = null; HttpClient client = GetClient(); HttpResponseMessage response = client.GetAsync($"/v2/top-headlines?sources={source}&apiKey={apiKey}").Result; if (response.IsSuccessStatusCode) { ArticleRoot root = response.Content.ReadAsAsync <ArticleRoot>().Result; articleList = root.Articles; } return(articleList.Take(5).ToList()); }
public void LoadArticles() { if (listView_Single.SelectedItems.Count == 1) { ListViewItem itm = listView_Single.SelectedItems[0]; ArticleRoot articles = Controller.GetArticles((int)itm.Tag); int isFoil = -1; switch (comboBox_Foil.Text) { case "Yes": isFoil = 1; break; case "No": isFoil = 0; break; } int isFirstEdition = -1; switch (comboBox_FirstEdition.Text) { case "Yes": isFirstEdition = 1; break; case "No": isFirstEdition = 0; break; } string condition = comboBox_Condition.Text; if (condition == "-") { condition = ""; } listView_Article.Items.Clear(); listView_Article.BringToFront(); foreach (Article.Article article in articles.GetArticleByFilter("German", condition, isFoil, isFirstEdition)) { ListViewItem itmNew = new ListViewItem(article.ToString()); itmNew.Tag = article.idArticle; ListViewAddItem(listView_Article, itmNew, label_Article); } } }
} // End of the AddOrderRows method /// <summary> /// Add supplier invoice rows recursively /// </summary> private async Task AddSupplierInvoiceRows(IList<ProductRow> product_rows, IList<SupplierInvoiceRow> supplier_invoice_rows) { // Loop product rows foreach (ProductRow row in product_rows) { // Unit if (string.IsNullOrEmpty(row.unit_code) == false) { row.unit_code = CommonTools.ConvertToAlphanumeric(row.unit_code).ToLower(); await AddUnit(row.unit_code); } // Article, add if there is an identifier ArticleRoot article_root = null; if (string.IsNullOrEmpty(row.product_code) == false || string.IsNullOrEmpty(row.manufacturer_code) == false || string.IsNullOrEmpty(row.gtin) == false) { article_root = await AddArticle(row); } // Add a supplier invoice row supplier_invoice_rows.Add(new SupplierInvoiceRow { ArticleNumber = article_root != null ? article_root.Article.ArticleNumber : null, Account = article_root == null ? this.default_values.PurchaseAccount : null, ItemDescription = row.product_name, Quantity = row.quantity, Price = row.unit_price //Unit = article_root != null ? article_root.Article.Unit : row.unit_code }); // Check if there is sub rows if (row.subrows != null && row.subrows.Count > 0) { await AddSupplierInvoiceRows(row.subrows, supplier_invoice_rows); } } } // End of the AddSupplierInvoiceRows method
} // End of the AddOfferRows method /// <summary> /// Add order rows recursively /// </summary> private async Task AddOrderRows(IList<ProductRow> product_rows, IList<OrderRow> order_rows) { // Loop product rows foreach (ProductRow row in product_rows) { // Unit if (string.IsNullOrEmpty(row.unit_code) == false) { row.unit_code = CommonTools.ConvertToAlphanumeric(row.unit_code).ToLower(); await AddUnit(row.unit_code); } // Article, add if there is an identifier ArticleRoot article_root = null; if (string.IsNullOrEmpty(row.product_code) == false || string.IsNullOrEmpty(row.manufacturer_code) == false || string.IsNullOrEmpty(row.gtin) == false) { article_root = await AddArticle(row); } // Add a order row order_rows.Add(new OrderRow { ArticleNumber = article_root != null ? article_root.Article.ArticleNumber : null, Description = row.product_name, OrderedQuantity = row.quantity, DeliveredQuantity = row.quantity, Price = row.unit_price, Unit = article_root != null ? article_root.Article.Unit : row.unit_code }); // Check if there is sub rows if (row.subrows != null && row.subrows.Count > 0) { await AddOrderRows(row.subrows, order_rows); } } } // End of the AddOrderRows method
public void LoadBulk() { LoadSingles(); double price = 0.0; if (listView_Single.Items.Count > 0) { treeView_Bulk.Nodes.Clear(); progressBar1.Value = 0; progressBar1.Maximum = listView_Single.Items.Count; Dictionary <string, List <double> > offers = new Dictionary <string, List <double> >(); List <string> notFoundCards = new List <string>(); for (int i = 0; i < listView_Single.Items.Count; i++) { progressBar1.Value = i + 1; ListViewItem singleItem = listView_Single.Items[i]; ArticleRoot articles = Controller.GetArticles((int)singleItem.Tag); int isFoil = -1; switch (comboBox_Foil.Text) { case "Yes": isFoil = 1; break; case "No": isFoil = 0; break; } int isFirstEdition = -1; switch (comboBox_FirstEdition.Text) { case "Yes": isFirstEdition = 1; break; case "No": isFirstEdition = 0; break; } string condition = comboBox_Condition.Text; if (condition == "-") { condition = ""; } Article.Article article = null; try { article = articles.GetArticleByFilter("German", condition, isFoil, isFirstEdition).OrderBy(a => a.price).First(); } catch { } if (article != null) { if (!offers.ContainsKey(article.seller.username)) { offers.Add(article.seller.username, new List <double>()); } offers[article.seller.username].Add(article.price); bool match = false; foreach (TreeNode node in treeView_Bulk.Nodes) { if (node.Text == article.seller.username) { match = true; node.Nodes.Add("(" + singleItem.Text + ") " + article.ToString()); } } if (!match) { TreeNode userNode = treeView_Bulk.Nodes.Add(article.seller.username); userNode.Nodes.Add("(" + singleItem.Text + ") " + article.ToString()); } } else { notFoundCards.Add("(" + singleItem.Text + ")"); } price = 0d; foreach (string sellers in offers.Keys) { double currentPrice = offers[sellers].Sum(); int currentCount = offers[sellers].Count(); price += currentPrice; price += Shipping.GetShippingPrice(currentCount, currentPrice, (comboBox_Bulk.Text == "YES")); } label_Bulk_Price.Text = "Price: " + String.Format("{0:0.00}", price); Application.DoEvents(); } progressBar1.Value = 0; if (notFoundCards.Count > 0) { TreeNode notFoundNode = treeView_Bulk.Nodes.Add("Not found"); foreach (string lost in notFoundCards) { notFoundNode.Nodes.Add(lost); } } } else { MessageBox.Show("No singles for Bulk-Function"); } }