Пример #1
0
        public void GetAllFromSameOrderTest()
        {
            AddToOrderDAL dal    = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            var           result = dal.FromSameOrder(6);

            Assert.IsTrue(result.Count != 0, "no items shown");;
        }
Пример #2
0
        public void GetItemTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            Assert.IsTrue(result.GetItem(4).ItemID == 4, "Cannot find the item");
        }
Пример #3
0
        public void GetCustomerTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            Assert.IsTrue(result.GetCustomer(2).CustomerID == 2, "Cannot find the customer");
        }
Пример #4
0
        public void DeleteOrderTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            result.DeleteOrder(1);
            Assert.IsTrue(result.GetOrder(1).OrderID != 1, "Order was not deleted");
        }
Пример #5
0
        public void CompleteOrderTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            result.CompleteOrder(2);
            Assert.IsTrue(result.CompleteOrder(2).Comment == "Completed", "Order was not comleted");
        }
Пример #6
0
        public void DeleteItemTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            result.RemoveItem(33);
            Assert.IsTrue(result.GetItem(33).ItemID != 33, "Item was not deleted");
        }
Пример #7
0
        public void LogTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            result.Log("Test2", "Test2");
            Assert.IsTrue(result.Log("Test2", "Test2") == true, "Customer was not logged");
        }
Пример #8
0
        public void GetItemTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            result.GetItem(1);
            Assert.IsTrue(result.GetItem(1).ItemID == 1, "Item was not found");
        }
Пример #9
0
        public void DeleteCustomerTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            result.RemoveCustomer(3);
            Assert.IsTrue(result.GetCustomer(3).CustomerID != 3, "Customer was not deleted");
        }
Пример #10
0
        public void DeletePositionTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            result.DeletePosition(1);
            Assert.IsTrue(result.SameOrderPositions(1).Count == 0, "Position was not deleted");
        }
Пример #11
0
        public void GetShipperTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            result.GetShipper(2);
            Assert.IsTrue(result.GetShipper(2).ShipperID == 2, "Shipper was not found");
        }
Пример #12
0
        public void CreateAddToOrderTest()
        {
            AddToOrderDAL dal = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);



            var result = new AddToOrderDTO
            {
                OrderIDKEY = 5,
                ItemIDKEY  = 1,
                Amount     = 28
            };

            result = dal.CreateAddToOrder(result);
            Assert.IsTrue(result.OrderIDKEY == 5 && result.ItemIDKEY == 1, "AddToOrder was not created");
        }
Пример #13
0
        static void Main(string[] args)
        {
            IShipperDAL _shipperDAL = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            IItemDAL _itemDAL = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString); ;
            ICustomerDAL _customerDAL = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString); ;
            IOrderDAL _orderDAL = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString); ;
            IAddToOrderDAL _addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
           
            
            ICustomer user2 = new Customer(_customerDAL, _addtoorderDAL, _itemDAL, _orderDAL);
            IUser user1 = new User(_shipperDAL, _itemDAL, _customerDAL, _orderDAL, _addtoorderDAL);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new RoleChoiceForm(user1,user2));
        }
Пример #14
0
        public void UpdateItemTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);
            var           item          = new ItemDTO
            {
                ItemID  = 32,
                Price   = 25,
                OnStock = 20
            };

            Assert.IsTrue(result.ChangeItem(item).Price == 25, "Item was not updated");
        }
Пример #15
0
        public void UpdateCustomerTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);
            var           customer      = new CustomerDTO
            {
                EMail       = "EmailTest",
                CustomerID  = 2,
                Phone       = "TestPhone",
                Addres      = "TestAddress",
                Description = "TestDescription"
            };

            Assert.IsTrue(result.ChangeCustomer(customer).EMail == "EmailTest", "Customer was not updated");
        }
Пример #16
0
        public void AddCustomerTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);

            var customer = new CustomerDTO
            {
                EMail       = "Test2",
                Addres      = "Test2",
                Phone       = "Test2",
                Description = "Test2"
            };

            result.AddCustomer(customer);
            Assert.IsTrue(customer.CustomerID >= 0, "returned ID should be more than zero");
        }
Пример #17
0
        public void AddItemTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);
            var           item          = new ItemDTO
            {
                Name    = "BL Test",
                Price   = 100,
                OnStock = 2
            };



            var r = result.AddItem(item);

            Assert.IsTrue(r.ItemID != 0, "returned ID should be more than zero");
        }
Пример #18
0
        public void AddShipperTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            var shipper = new ShipperDTO
            {
                Login       = "******",
                Password    = new ConsoleProject.PasswordActions().PasswordEncryption("1234"),
                EMail       = "Test2",
                Addres      = "Test2",
                Phone       = "Test2",
                Description = "Test2"
            };

            shipper = result.AddShipper(shipper);
            Assert.IsTrue(shipper.ShipperID >= 0, "returned ID should be more than zero");
        }
Пример #19
0
        public void AddOrderTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            Customer      result        = new Customer(customerDAL, addtoorderDAL, itemDAL, orderDAL);
            var           order         = new OrderDTO
            {
                ShipperIDKEY  = 2,
                CustomerIDKEY = 2,
                Price         = 0.00,
                Date          = DateTime.Now,
                Comment       = "No info"
            };



            var r = result.AddOrder(order);

            Assert.IsTrue(r.OrderID != 0, "returned ID should be more than zero");
        }
Пример #20
0
        public void MENU(int user)
        {
            string conn = ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString;
            ConsoleProgramFunctions Login = new ConsoleProgramFunctions(connectionString);
            ItemDAL       itemD           = new ItemDAL(conn);
            AddToOrderDAL addD            = new AddToOrderDAL(conn);
            CustomerDAL   customerD       = new CustomerDAL(conn);
            OrderDAL      orderD          = new OrderDAL(conn);
            ShipperDAL    shipperD        = new ShipperDAL(conn);


            Item       item     = new Item(itemD);
            AddToOrder add      = new AddToOrder(addD);
            Customer   customer = new Customer(customerD);
            Order      order    = new Order(orderD);
            Shipper    shipper  = new Shipper(shipperD);



            Console.Clear();

            if (user > 0)
            {
                Console.WriteLine($"WELCOME  {shipper.GetShipper(user).Login}");
                Console.WriteLine("CHOOSE OPTION TO CONTINUE:\n" + "1-WORK WITH ITEMS\n" + "2-WORK WITH ORDERS\n" + "3-SHOW CUSTOMERS\n" + "4-SIGH OUT\n" + "ANYTHING ELSE TO CLOSE PROGRAM\n" + "MY OPTION:");
                int choice = Convert.ToInt32(Console.ReadLine());
                Console.Clear();
                if (choice == 1)
                {
                    item.ShowItems();
                    Console.WriteLine("\n PRESS \n 1-TO FIND ITEM BY ID\n" + "2-TO GET ITEMS SORTED \n 3- TO ADD NEW ITEM \n ANYTHING ELSE TO RETURN TO MENU\n MY OPTION:");
                    choice = Convert.ToInt32(Console.ReadLine());
                    Console.Clear();
                    if (choice == 1)
                    {
                        Console.WriteLine("ENTER ITEM ID TO SHOW:");
                        int ItemID = Convert.ToInt32(Console.ReadLine());
                        item.GetItem(ItemID);
                        Console.WriteLine("ENTER 1 TO DELETE OR 2 TO UPDATE OR ANYTHING ELSE TO RETURN TO MENU:");
                        choice = Convert.ToInt32(Console.ReadLine());
                        if (choice == 1)
                        {
                            Console.WriteLine("ITEM {ItemID} WAS SUCCESSFULLY DELETED\n");

                            item.RemoveItem(ItemID);
                            Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                            Console.ReadLine();
                            MENU(user);
                        }
                        if (choice == 2)
                        {
                            Console.WriteLine("ENTER ITEM ID TO UPDATE:");
                            choice = Convert.ToInt32(Console.ReadLine());
                            ItemDTO t = new ItemDTO();
                            item.ChangeItem(t);
                            Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                            Console.ReadLine();
                            MENU(user);
                        }
                        else
                        {
                            MENU(user);
                        }
                    }
                    if (choice == 2)
                    {
                        Console.WriteLine("Enter number to get items sorted \n 1-Price Ascending \n 2-Price Descending \n 3-Newer to Older \n Anything else for older first");
                        choice = Convert.ToInt32(Console.ReadLine());
                        item.ShowItemsSorted(choice);
                        Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                        Console.ReadLine();
                        MENU(user);
                    }
                    if (choice == 3)
                    {
                        ItemDTO t = new ItemDTO();
                        item.AddItem(t);
                        Console.WriteLine("ITEM WAS SUCCESFULLY CREATED\n");
                        Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                        Console.ReadLine();
                        MENU(user);
                    }
                    else
                    {
                        MENU(user);
                    }
                }


                if (choice == 2)
                {
                    order.ShowOrders(user);


                    Console.WriteLine("\n PRESS \n 1-TO FIND ORDER BY ID\n" + "2-TO GET ORDERS SORTED \n ANYTHING ELSE TO RETURN TO MENU\n MY OPTION:");
                    choice = Convert.ToInt32(Console.ReadLine());
                    Console.Clear();
                    if (choice == 1)
                    {
                        Console.WriteLine("ENTER ORDER ID TO SHOW:");
                        int OrderID = Convert.ToInt32(Console.ReadLine());
                        order.GetOrder(OrderID);
                        Console.WriteLine("ENTER 1 TO CANCEL ORDER OR 2 TO COMPLETE ORDER OR ANYTHING ELSE TO RETURN TO MENU:");
                        choice = Convert.ToInt32(Console.ReadLine());
                        if (choice == 1)
                        {
                            order.RemoveOrder(OrderID);
                            Console.WriteLine($"ORDER {OrderID} has been successfully canceled");

                            Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                            Console.ReadLine();
                            MENU(user);
                        }
                        if (choice == 2)
                        {
                            ItemDTO t = new ItemDTO();
                            item.ChangeItem(t);
                            Console.WriteLine($"Order has been successfully completed");
                            Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                            Console.ReadLine();
                            MENU(user);
                        }
                        else
                        {
                            MENU(user);
                        }
                    }
                    if (choice == 2)
                    {
                        Console.WriteLine("Enter number to get orders sorted \n 1-Older first \n 2- Newer first \n 3-Completed first \n Anything else reccomended");
                        choice = Convert.ToInt32(Console.ReadLine());
                        item.ShowItemsSorted(choice);
                        Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                        Console.ReadLine();
                        MENU(user);
                    }

                    else
                    {
                        MENU(user);
                    }
                }
                if (choice == 3)
                {
                    Console.WriteLine("PRESS ANYTHING TO RETURN TO MENU");
                    Console.ReadLine();
                    MENU(user);
                    customer.ShowCustomers();
                }
                if (choice == 4)
                {
                    Login.Login();
                }
                else
                {
                    Thread.Sleep(2000);
                    Console.Clear();
                }
            }
        }
Пример #21
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            base.OnStartup(e);
            //RegisterUnity();

            //UnityContainer newContainer = new UnityContainer();
            // newContainer.RegisterType<User>();
            //    new InjectionConstructor("LoginShipperModel"));


            Container = new UnityContainer();

            Container.RegisterType <IItemDAL, ItemDAL>()
            .RegisterType <IOrderDAL, OrderDAL>()
            .RegisterType <IAddToOrderDAL, AddToOrderDAL>()
            .RegisterType <IShipperDAL, ShipperDAL>()
            .RegisterType <IUser, User>()
            ;
            //.RegisterType<IAuthManager, AuthManager>();

            //RegisterAutoMapper();

            MapperConfiguration config = new MapperConfiguration(
                cfg =>
            {
                cfg.AddMaps(typeof(User).Assembly);
            });

            Container.RegisterInstance(config.CreateMapper());



            IShipperDAL    _shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            IItemDAL       _itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            ICustomerDAL   _customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            IOrderDAL      _orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            IAddToOrderDAL _addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);


            ICustomer user2 = new Customer(_customerDAL, _addtoorderDAL, _itemDAL, _orderDAL);
            IUser     user1 = new User(_shipperDAL, _itemDAL, _customerDAL, _orderDAL, _addtoorderDAL);
            // ItemDTO item = user1.GetItem(1);
            //ItemDetailsModel l = new ItemDetailsModel(user1, item);
            //ItemDetails j = new ItemDetails(l);
            //  j.ShowDialog();
            LoginShipperModel lm  = new LoginShipperModel(user1);
            ItemsListModel    lm1 = new ItemsListModel(user1);
            //var key = typeof(MainWindow).ToString();
            // LoginShipper lf = Container.Resolve<LoginShipper>();
            LoginShipper lf     = new LoginShipper(lm);
            bool         result = lf.ShowDialog() ?? false;
            // Window1 w = Container.Resolve<Window1>();
            // bool result = w.ShowDialog() ?? false;
            // if (result)
            {
                MessageBox.Show("YEP");
                //ItemsList ml = Container.Resolve<ItemsList>();
                ItemsList ml = new ItemsList(lm1);
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                Current.MainWindow   = ml;
                ml.Show();
            }
            //else
            //{
            //    Current.Shutdown();
            //}
        }