private static void Main(string[] args) { IShopService shopService = new ShopService(); try { //order and sell var article = shopService.OrderArticle(1, 20); shopService.SellArticle(10, article); //print article on console article = shopService.GetArticleById(1); if (article == null) { Console.WriteLine("Article not found: "); } Console.WriteLine("Found article with ID: " + article.ID); //print article on console article = shopService.GetArticleById(12); if (article == null) { Console.WriteLine("Article not found: "); } Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
/// <summary> /// Displays an article on console, if it exists /// </summary> /// <param name="articleId">Article id</param> private static void FindAndDisplayArticleOnConsole(int articleId) { var article = _shopService.GetArticleById(articleId); Console.WriteLine( String.Format("{0}: {1}", article.ID != -1 ? "Found article with ID" : "Could not find article with ID", articleId)); }