Exemplo n.º 1
0
        private static void GetCustomersTest()
        {
            ICustomersService customersService = new FakeCustomersService();

            List <Customer> customers = customersService.Get();

            // snippet: foreach
            foreach (Customer customer in customers)
            {
                // snippet: cw
                Console.WriteLine(customer);

                // customersService.Calculate(customer);
            }
        }
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));
        }