Exemplo n.º 1
0
        private static void GetItemsTest()
        {
            IItemsService itemsService = new FakeItemsService();

            List <Item> items = itemsService.Get();

            List <Product> products = items.OfType <Product>().ToList();

            foreach (Item item in items)
            {
                Console.WriteLine(item);

                item.Print();
            }

            foreach (Product product in products)
            {
                product.Print();
            }
        }
Exemplo n.º 2
0
        private static void CreateOrderTest()
        {
            Console.WriteLine("Witaj w naszym sklepie!");

            Console.WriteLine("Podaj id klienta:");
            int customerId = int.Parse(Console.ReadLine());

            Console.WriteLine("Podaj id produktu:");
            int productId = int.Parse(Console.ReadLine());

            Console.WriteLine("Podaj ilość:");
            int quantity = int.Parse(Console.ReadLine());

            // TODO: pobrac klienta i produkt ze zrodla danych

            ICustomersService customersService = new FakeCustomersService();
            IItemsService     itemsService     = new FakeItemsService();

            // Przygotowanie danych
            Generator.Generator generator = new Generator.Generator();
            var customers = generator.GetCustomers(100);

            customersService.Add(customers);

            var products = generator.GetProducts(50);
            var services = generator.GetServices(50);

            // połączenie zbiorów
            var items = products.OfType <Item>().Concat(services).ToList();

            itemsService.Add(items);


            // Pobranie
            Customer customer = customersService.Get(customerId);
            Item     item     = itemsService.Get(productId);

            Order order = new Order("ZA 001", customer);

            order.Details.Add(new OrderDetail(item, quantity));
        }