Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            UserController userController = new UserController(DBWorker.getMysqlConnection());

            //get by ID
            Console.WriteLine("Get by ID");
            Console.WriteLine(userController.getUserById(2));
            Console.WriteLine("============================");
            //чтобы консоль не закрывалась
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            UserController userController = new UserController(DBWorker.getMysqlConnection());

            //get by ID
            Console.WriteLine("Get by ID");
            Console.WriteLine(userController.getUserById(2));
            Console.WriteLine("============================");

            ////add users in List and show all
            Console.WriteLine("Show All Users");
            printListInfo(userController.GetAllUsers());
            Console.WriteLine("============================");

            //adding new user
            Console.WriteLine("Adding New User");
            userController.addUser(new User("Sveta", "babydoll", "sveta94", "Obolon", 26));
            printListInfo(userController.GetAllUsers());
            Console.WriteLine("============================");

            //updating user
            Console.WriteLine("Updating User");
            userController.updateUser(new User(6, "Vika", "vikusya", "victory000", "Nyvky", 40));
            printListInfo(userController.GetAllUsers());
            Console.WriteLine("============================");

            //deleting by id
            Console.WriteLine("Deleting by ID");
            userController.dellUserById(7);
            printListInfo(userController.GetAllUsers());
            Console.WriteLine("============================");

            ///////////////////////////////////////////////////////////////////////////////////
            OrderController orderController = new OrderController(DBWorker.getMysqlConnection());

            //get by ID
            Console.WriteLine("Get by ID");
            Console.WriteLine(orderController.getOrderById(2));
            Console.WriteLine("============================");

            //add orders in List and show all
            Console.WriteLine("Show All Orders");
            printListInfo(orderController.GetAllOrders());
            Console.WriteLine("============================");

            //adding new order
            Console.WriteLine("Adding New Order");
            orderController.addOrder(new Order(2, userController.getUserById(4)));
            printListInfo(orderController.GetAllOrders());
            Console.WriteLine("============================");

            //updating order
            Console.WriteLine("Updating Order");
            orderController.updateOrder(new Order(3, 3, userController.getUserById(3)));
            printListInfo(orderController.GetAllOrders());
            Console.WriteLine("============================");

            //deleting by id
            Console.WriteLine("Deleting by ID");
            orderController.dellOrderById(5);
            printListInfo(orderController.GetAllOrders());
            Console.WriteLine("============================");

            //чтобы консоль не закрывалась
            Console.ReadKey();
        }