コード例 #1
0
ファイル: Program.cs プロジェクト: sulmar/Altkom.EF.201807
        private static void GetCustomerTest()
        {
            ICustomersService customersService = new DbCustomersService();

            var customer = customersService.Get(1);

            Console.WriteLine(customer.FullName);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sulmar/Altkom.EF.201807
        private static void UpdateCustomerTest()
        {
            using (ICustomersService customersService = new DbCustomersService())
            {
                var customer = customersService.Get(1);

                customer.FirstName = "Kasia";

                customersService.Update(customer);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: sulmar/Altkom.EF.201807
        private static void GetCustomersTest()
        {
            using (ICustomersService customersService = new DbCustomersService())
            {
                var customers = customersService.Get();

                foreach (var customer in customers)
                {
                    Console.WriteLine(customer.FullName);
                }
            }
        }
コード例 #4
0
        private static void AddCustomerTest()
        {
            var customer1 = new Customer("Marcin", "Sulecki");
            var customer2 = new Customer("Bartek", "Sulecki");

            // ICustomersService customersService = new MockCustomersService();

            ICustomersService customersService = new DbCustomersService();

            customersService.Add(customer1);
            customersService.Add(customer2);

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

            foreach (var customer in customers)
            {
                Console.WriteLine(customer);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: sulmar/Altkom.EF.201807
        private static void AddOrderTest()
        {
            var address = new Address
            {
                City     = "Warszawa",
                PostCode = "01466",
                Street   = "Chłodna"
            };

            //var customer = new Customer
            //{
            //    FirstName = "Marcin",
            //    LastName = "Sulecki",
            //    DeliveryAddress = address,
            //    Birthday = DateTime.Now
            //};

            ICustomersService customersService = new DbCustomersService();
            var customer = customersService.Get(1);

            var product1 = new Product
            {
                Id    = 1,
                Name  = "Mysz",
                Color = "Red"
            };

            var service1 = new Service
            {
                Id   = 2,
                Name = "Szkolenie EF"
            };

            var product2 = new Product
            {
                Id    = 3,
                Name  = "Klawiatura",
                Color = "Blue"
            };

            var order = new Order
            {
                Customer  = customer,
                DateOrder = DateTime.Now,
            };

            order.Details.Add(new OrderDetail
            {
                Item      = product1,
                Quantity  = 3,
                UnitPrice = 99
            });

            order.Details.Add(new OrderDetail
            {
                Item      = service1,
                Quantity  = 5,
                UnitPrice = 100
            });


            var od = new OrderDetail
            {
                Item      = product2,
                Quantity  = 5,
                UnitPrice = 200
            };

            order.Details.Add(od);

            order.Details.Add(od);

            IOrdersService ordersService = new DbOrdersService();

            ordersService.Add(order);
        }