コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kiso3/TheShop
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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();
        }