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(); }
private static void Main(string[] args) { var shopService = new ShopService(); Article article = null; IUnitOfWork unitOfWork; try { //order and sell article = shopService.OrderArticle(articleId1, maxExpectedPrice); shopService.SellArticle(article, buyerId); } catch (ArticalNotFoundException ae) { Console.WriteLine(ae.Message); } catch (NotSavedArticleException nsae) { Console.WriteLine(nsae.Message); } catch (Exception ex) { Console.WriteLine(ex); } try { unitOfWork = new UnitOfWork(); article = unitOfWork.ArticleRepository.GetArticleById(articleId1); //print article on console Console.WriteLine("Found article with ID: " + article.ID); } catch (ArticalNotFoundException anfex) { Console.WriteLine($"Article with id:{articleId1} not found"); } catch (Exception ex) { Console.WriteLine($"Article with id:{articleId1} not found"); } try { unitOfWork = new UnitOfWork(); article = unitOfWork.ArticleRepository.GetArticleById(articleId12); //print article on console Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine($"Article with id:{articleId12} not found"); } Console.ReadKey(); }
private static void Main(string[] args) { var shopService = new ShopService(); //order and sell shopService.OrderAndSellArticle(1, 20, 10); //print article on console shopService.FindAndPrint(1); shopService.FindAndPrint(12); Console.ReadKey(); }
private static void Main(string[] args) { CreateSuppliers(); _shopService = new ShopService(new DatabaseDriver(), new Logger(), _suppliers); OrderAndSellArticle(1, 1000, 10); FindAndDisplayArticleOnConsole(1); FindAndDisplayArticleOnConsole(9); Console.ReadKey(); }
private static void Main(string[] args) { var shopService = new ShopService(); //try //{ // shopService.OrderAndSellArticle(1, 20000, 10); // var article = shopService.GetById(1); // if (article != null) // { // Console.WriteLine("Found article with ID: " + article.ID + "Price of: " + article.ArticlePrice); // } // else // { // throw new Exception("Could not fint article with ID: " + 1); // } // article = shopService.GetById(12); // if (article != null) // { // Console.WriteLine("Found article with ID: " + article.ID + "Price of: " + article.ArticlePrice); // } // else // { // throw new Exception("Could not fint article with ID: " + 12); // } //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} try { shopService.OrderAndSellArticle(1, 20000, 10); var article = shopService.GetById(1); article = shopService.GetById(12); shopService.OrderAndSellArticle(3, 161, 11); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
private static void Main(string[] args) { List <ISupplire> supplires = new List <ISupplire>() { new Supplier1(), new Supplier2(), new Supplier3() }; ShopService shopService = new ShopService(new DatabaseDriver(), new Logger(), supplires); try { Func <Article, bool> articlePriceLessThen = a => a.ArticlePrice <= 458; //order and sell shopService.OrderAndSellArticle(1, articlePriceLessThen, 10); } catch (Exception ex) { Console.WriteLine(ex); } try { //print article on console var article = shopService.GetById(1); Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } try { //print article on console var article = shopService.GetById(12); Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } Console.ReadKey(); }
private static void Main(string[] args) { IShopService shopService = new ShopService( new DatabaseDriver <Article>(), new Logger(), new SupplierHierarchyFactory()); try { //order and sell shopService.OrderAndSellArticle(1, 20, 10); } catch (Exception ex) { Console.WriteLine(ex); } try { //print article on console var article = shopService.GetById(1); Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } try { //print article on console var article = shopService.GetById(12); Console.WriteLine("Found article with ID: " + article.ID); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } Console.ReadKey(); }
private static void Main(string[] args) { var shopService = new ShopService(); try { //order and sell shopService.OrderAndSellArticle(1, 20, 10); } catch (Exception ex) { Console.WriteLine(ex); } try { //print article on console var article = shopService.GetById(1); Console.WriteLine("Found article with ID: " + article.Id); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } try { //print article on console var article = shopService.GetById(12); Console.WriteLine("Found article with ID: " + article.Id); } catch (Exception ex) { Console.WriteLine("Article not found: " + ex); } Console.ReadKey(); }
private static void Main(string[] args) { #region configuration DatabaseContext context = new InMemoryDatabaseDatabaseContext(); ILogger logger = new ConsoleLogger(); var dataProvider = new InMemoryDataSeeder(context); dataProvider.AddInitialData(); IShopService shopService = new ShopService(context, logger); #endregion shopService.OrderAndSellArticle(1, 20, 10); Article article = shopService.GetById(1); shopService.DisplayArticle(article); Article newArticle = shopService.GetById(12); shopService.DisplayArticle(newArticle); Console.ReadKey(); }