Esempio n. 1
0
        internal static bool CreateOrderMenu(IOrdersRepository order, IProductsRepository product, IOrderDetalisRepository orderDetalis)
        {
            Console.Clear();
            OrdersView.CreateOrderMenu();
            switch (Console.ReadLine())
            {
            case "1":
                OrdersView.NotImplementedYet();
                OrdersView.PressAnyKey();
                return(true);

            case "2":
                OrdersView.NotImplementedYet();
                OrdersView.PressAnyKey();
                return(true);

            case "3":
                GetNewOrderInput(order);
                bool showMenu = true;
                while (showMenu)
                {
                    showMenu = MainMenu(order, product, orderDetalis);
                }
                return(true);

            case "0":
                return(false);

            default:
                Console.WriteLine("There is no such choice");
                OrdersView.PressAnyKey();
                return(true);
            }
        }
Esempio n. 2
0
        static bool getPay(IOrdersRepository order)
        {
            Console.WriteLine($"Do you want to pay {TotalPrice} y/n");

            switch (Console.ReadLine())
            {
            case "y":
                order.UpdateOrder(UpdateStatus(2));
                GetNewOrderInput(order);
                return(false);

            case "n":
                return(false);

            default:
                Console.WriteLine("There is no such choice");
                OrdersView.PressAnyKey();
                return(true);
            }
        }
Esempio n. 3
0
        internal static bool MainMenu(IOrdersRepository order, IProductsRepository product, IOrderDetalisRepository orderDetalis)

        {
            Console.Clear();
            OrdersView.PrintMenu(CustomerId, OrderId);

            switch (Console.ReadLine())
            {
            case "6":
                order.UpdateOrder(UpdateStatus(1));
                GetIdAndAmount(orderDetalis.GetAllOrdersDetalis(OrderId), product);
                GetNewOrderInput(order);
                return(true);

            case "1":
                Console.Clear();
                ProductsView.printList(product.GetAllProducts());
                bool ProductInBase = true;
                var  addorder      = new OrderDetalis(OrderId);
                while (ProductInBase)
                {
                    addorder = GetInput();
                    if (IsProductIdInBase(product, addorder))
                    {
                        ProductInBase = CheckLessThanZero(product, addorder);
                    }
                    else
                    {
                        ProductInBase = true;
                    }
                }
                if (orderDetalis.AddOrderDetalis(addorder) == true)
                {
                    OrdersView.AddedSuccessfully();
                }
                var updateProduct = new Products(addorder.product_id, addorder.Amount);
                product.UpdateProduct(updateProduct);
                orderDetalis.UpdatePrice(addorder);
                return(true);

            case "2":
                Console.Clear();
                GetOrderList(orderDetalis);
                OrdersView.PressAnyKey();
                return(true);

            case "3":
                if (!IsAnyProductInBase(orderDetalis))
                {
                    Console.WriteLine("Buy something first");
                    OrdersView.PressAnyKey();
                }
                else
                {
                    Console.Clear();
                    GetOrderList(orderDetalis);
                    var updateDetalis = GetInput();
                    var amount        = orderDetalis.GetCurrentAmount(updateDetalis);
                    product.UpdateProductUp(amount);
                    orderDetalis.UpdateOrderDetalis(updateDetalis);
                    orderDetalis.UpdatePrice(updateDetalis);
                    var updateAmount = new Products(updateDetalis.product_id, updateDetalis.Amount);
                    product.UpdateProduct(updateAmount);
                    return(true);
                }
                return(true);

            case "4":
                GetIdAndAmount(orderDetalis.GetAllOrdersDetalis(OrderId), product);
                orderDetalis.DeleteOrderDetalis(OrderId);
                return(true);

            case "5":
                bool showMenu = true;
                while (showMenu)
                {
                    showMenu = getPay(order);
                }
                return(true);

            case "0":
                GetIdAndAmount(orderDetalis.GetAllOrdersDetalis(OrderId), product);
                order.UpdateOrder(UpdateStatus(1));
                return(false);

            default:
                Console.WriteLine("There is no such choice");
                OrdersView.PressAnyKey();
                return(true);
            }
        }