Exemplo n.º 1
0
        public void CreateOrderTestTrue() // check crt order user id vs item id true
        {
            UserBL userbl = new UserBL();
            Order  order  = new Order();

            order.user      = new User();
            order.OrderItem = new Item();
            ItemBL id = new ItemBL();

            order.ListItem     = new List <Item>();
            order.user.user_id = 1;

            order.ListItem.Add(id.GetItemByID(101));
            Assert.True(orderBL.CreateOrder(order));
        }
Exemplo n.º 2
0
        public bool InsertOrder(Customer customer, Order order)
        {
            bool   checkpay        = false;
            bool   checkDeleteCart = false;
            string path            = Path.GetFullPath("DataCart" + customer.Username + ".txt");

            try
            {
                checkpay = orderbl.CreateOrder(order);
                if (checkpay == true)
                {
                    checkDeleteCart = DeleteFileCart(path);
                    if (checkDeleteCart == true)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
            }
            if (checkpay == false)
            {
                checkDeleteCart = false;
                return(false);
            }
            return(false);
        }
        public void CreateOrderTest()
        {
            OrderBL  orderBL  = new OrderBL();
            DateTime dateTime = new DateTime(2019, 12, 22);
            Order    order    = new Order(1, null, dateTime, 10);

            Assert.False(orderBL.CreateOrder(order));
        }
        public void CreateOrderTest2()
        {
            OrderBL  orderBL  = new OrderBL();
            DateTime dateTime = new DateTime(2019, 1, 8);
            Order    order    = new Order(2, null, dateTime, 13);

            Assert.False(orderBL.CreateOrder(order));
        }
        public void CreateOrderTest()
        {
            UserDAL userDAL = new UserDAL();
            ItemDAL itemDAL = new ItemDAL();
            Order   order   = new Order();

            order.OrderUser = new User();
            order.OrderItem = new Item();

            order.CartStatus = 0;
            order.OrderItem  = itemDAL.GetItemByID(2);
            order.OrderUser  = userDAL.GetUserById(1);
            orderDAL.CreateShoppingCart(order);

            Assert.True(orderBL.CreateOrder(order));

            orderBL.DeleteAllItemInShoppingCartByUserID(1);
        }
        public void CreateOrder(double total)
        {
            order.OrderUser = new Customer();
            OrderBL orderBL = new OrderBL();

            order.OrderUser = customer;
            try
            {
                if (orderBL.CreateOrder(order))
                {
                    Console.Clear();
                    customerBL.UpdateStatusShoppingCartById(true, customer.UserID);
                    Console.WriteLine("Shoes Stores");
                    List <Order> shoppingCart = new List <Order>();
                    shoppingCart = orderBL.ShowOrderUserPaySucess(customer.UserID);
                    Console.WriteLine("INVOICE");
                    Console.WriteLine("CUSTOMER'S NAME: {0}", shoppingCart[0].OrderUser.UserName);
                    Console.WriteLine("CUSTOMER'S EMAIL: {0}", shoppingCart[0].OrderUser.UserEmail);
                    Console.WriteLine("CODE ORDERS: {0}", shoppingCart[0].OrderId);
                    var tables = new List <ConsoleTable>();
                    var table  = new ConsoleTable("ID", "NAME", "PRICE");
                    foreach (var item in shoppingCart)
                    {
                        table.AddRow(item.OrderItem.ShoesId, item.OrderItem.ShoesName, FormatCurrency(item.OrderItem.ShoesPrice));
                        // tables.Add(table);
                    }
                    table.AddRow("", "", "");
                    table.AddRow("AMOUNT", "", shoppingCart[0].Amount);
                    table.AddRow("TOTAL AMOUNT", "", FormatCurrency(shoppingCart[0].Total));
                    table.AddRow("DATE", "", shoppingCart[0].OrderDate?.ToString("yyyy-MM-dd"));
                    tables.Add(table);
                    foreach (var item in tables)
                    {
                        item.Write();
                    }
                    Console.WriteLine("THANKS YOU");
                }
                else
                {
                    Console.WriteLine("Purchase failed");
                }
            }
            catch (System.Exception)
            {
                Console.WriteLine("NO MONEY????");
                throw;
            }


            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
        public void CreateOrder(double total)
        {
            order.OrderUser = new User();
            OrderBL orderBL = new OrderBL();

            order.OrderUser = user;
            try
            {
                if (orderBL.CreateOrder(order))
                {
                    // Console.Clear();
                    userBL.UpdateStatusShoppingCartById(true, user.UserID);

                    List <Order> shoppingCart = new List <Order>();
                    shoppingCart = orderBL.ShowOrderUserPaySucess(user.UserID);

                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("                Hóa Đơn                    ");
                    Console.WriteLine("TÊN KHÁCH HÀNG: {0}", shoppingCart[0].OrderUser.UserAccount);
                    Console.WriteLine("EMAIL KHÁCH HÀNG: {0}", shoppingCart[0].OrderUser.UserEmail);
                    Console.WriteLine("MÃ ĐƠN HÀNG: {0}", shoppingCart[0].OrderID);
                    // Console.WriteLine("-------------------------------------------");
                    var table = new ConsoleTable("MÃ ĐƠN HÀNG", "TÊN ĐỒ UỐNG", "SIZE", "GIÁ");
                    foreach (var item in shoppingCart)
                    {
                        table.AddRow(item.OrderID, item.OrderItem.ItemName, item.OrderItem.ItemSize, FormatCurrency(item.OrderItem.ItemPrice));
                    }
                    table.AddRow("", "", "", "");
                    table.AddRow("NGÀY MUA", "", "", shoppingCart[0].OrderDate?.ToString("yyyy-MM-dd"));
                    table.AddRow("TỔNG TIỀN", "", "", FormatCurrency(total));
                    table.Write();

                    Console.WriteLine("CÁM ƠN QUÝ KHÁCH");
                    Console.WriteLine("HẸN GẶP LẠI");
                }
                else
                {
                    Console.WriteLine("Không thể mua hàng");
                }
            }
            catch (System.Exception)
            {
                throw;
            }

            Console.WriteLine("Bấm phím bất kỳ để tiếp tục");
            Console.ReadKey();
        }
Exemplo n.º 8
0
        public void Create_test()
        {
            Orders or = new Orders();

            or.Customer       = new Customer();
            or.OrderID        = 1;
            or.Status         = "complete";
            or.Customer.CusID = 1;
            Items items = new Items();

            or.Items        = new List <Items>();
            items.ItemID    = 1;
            items.ItemPrice = 2;
            or.Items.Add(items);
            Assert.True(oBL.CreateOrder(or));
        }
Exemplo n.º 9
0
        public bool CreateOrder()
        {
            OrderBL obl    = new OrderBL();
            UserBl  ubl    = new UserBl();
            Orders  orders = new Orders();

            orders.shoesList    = new List <Shoes>();
            orders.Order_status = 1;
            orders.user         = new User();
            orders.user.User_id = id;
            orders.shoesList.Add(sbl.GetShoesById(sh_id));
            var getshoes = sbl.GetShoesById(sh_id);

            while (true)
            {
                try
                {
                    Console.Write("Input  Amount: ");
                    int amount1 = Convert.ToInt32(Console.ReadLine());
                    if ((amount1 > getshoes.Amount && getshoes.Amount == 0) || (amount1 == getshoes.Amount && getshoes.Amount == 0))
                    {
                        Console.WriteLine("Quantity no longer please put another product .. !");
                        Console.ReadLine();
                        Displaylistshoes();
                    }
                    if (amount1 > getshoes.Amount && getshoes.Amount > 0)
                    {
                        Console.WriteLine("Quantity in stock : {0}", getshoes.Amount);
                        throw (new valueexception("Not enough quantity , please re-enter: "));
                    }
                    else if (0 < amount1 || amount1 <= getshoes.Amount)
                    {
                        orders.shoesList[0].Amount = amount1;
                        break;
                    }
                }
                catch (valueexception e)
                {
                    Console.Write(e.Message);
                    continue;
                }
                catch
                {
                    Console.Write("Please enter a valid  :");
                    continue;
                }

                break;
            }
            Console.Write("Do you want to use the number of phone and current address to get unsigned ? :");
            string chon = Console.ReadLine();

            if (chon == "n")
            {
                Console.WriteLine("Please enter  phone number and address! ");
                while (true)
                {
                    Console.Write("-Enter recipient address :");
                    orders.Address = Console.ReadLine();
                    if (orders.Address != " ")
                    {
                        break;
                    }
                }
                Console.Write("-Enter the recipient's phone number :");
                while (true)
                {
                    orders.phone = Console.ReadLine();
                    if (IsValidString(orders.phone) == true)
                    {
                        break;
                    }
                    else
                    {
                        Console.Write("Please re-enter the recipient's phone number correctly : ");
                    }
                }
            }
            else
            {
                var userdt = ubl.GetUserByid(id);
                orders.Address = userdt.Address;
                orders.phone   = userdt.Phone;
            }

            Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
            Console.ReadLine();
            Displaylistshoes();
            return(true);
        }
Exemplo n.º 10
0
        public void ShoppingCart()
        {
            var     Or_us = obl.GetAllOrderByIDUser(id);
            decimal a     = 0;
            int     b     = Or_us.FindIndex(x => x.Order_status == 2);

            if (b == -1)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The list is empty, no invoices have been generated!");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.ReadLine();
            }
            else if (b != -1)
            {
                string line = "============================================================================================";
                Console.WriteLine(line);
                foreach (var orders in Or_us)
                {
                    if (orders.Order_status == 2)
                    {
                        var orderdetail = obl.GetOrderDetailsByID(orders.Order_id);
                        Console.Clear();
                        Console.WriteLine("SHOES STORE");
                        Console.WriteLine("          Shoe Sales Invoice        ");
                        Console.WriteLine("-Order date        : {0}", orderdetail.Date_Order);
                        Console.WriteLine("-Order ID          : {0}", orderdetail.Order_id);
                        Console.WriteLine(line);
                        Console.Write(" Product name      |  Unitprice          |  Amount          |  Size     |     Total          \n");
                        foreach (var order in orderdetail.shoesList)
                        {
                            Decimal c = order.Price * order.Amount;
                            Console.WriteLine("{0,-20} {1,-26} {2,-15} {3,-10} {4}", order.Shoes_name, order.Price, order.Amount, order.Size, c);
                            a += c;
                        }
                        Console.WriteLine(line);
                        Console.WriteLine("-The total amount payable                                                  {0}", a);
                    }
                }
                Console.WriteLine(line);
                Console.Write("Do you want to  order ?(y/n)");
                string choiceorder = Console.ReadLine();
                if (choiceorder == "y")
                {
                    Orders orders = new Orders();
                    orders.shoesList    = new List <Shoes>();
                    orders.Order_status = 1;
                    orders.user         = new User();
                    orders.user.User_id = id;
                    foreach (var order in Or_us)
                    {
                        if (order.user.User_id == id)
                        {
                            if (order.Order_status == 2)
                            {
                                oredr_iddelete = order.Order_id;
                                var detail = obl.GetOrderDetailsByID(order.Order_id);
                                foreach (var shoes in detail.shoesList)
                                {
                                    var shoesbyid = sbl.GetShoesById(shoes.Shoes_id);
                                    if (shoes.Amount > shoesbyid.Amount)
                                    {
                                        Console.WriteLine(" Insufficient quantity Would you like to cancel this product? (y/n)", shoesbyid.Amount);
                                        char c = Convert.ToChar(Console.ReadLine());
                                        if (c == 'y')
                                        {
                                            obl.Delete(order.Order_id, shoes.Amount);
                                            break;
                                        }
                                        else if (c == 'n')
                                        {
                                            orders.shoesList.Add(sbl.GetShoesById(shoes.Shoes_id));
                                            while (true)
                                            {
                                                Console.WriteLine("Please re-enter the product number: ");
                                                try{
                                                    int am = Convert.ToInt32(Console.ReadLine());
                                                    if ((am > shoesbyid.Amount && shoesbyid.Amount == 0) || (am == shoesbyid.Amount && shoesbyid.Amount == 0))
                                                    {
                                                        Console.WriteLine("Quantity no longer please put another product .. !");
                                                        Console.ReadLine();
                                                        break;
                                                    }
                                                    else if (am > shoesbyid.Amount)
                                                    {
                                                        throw new valueexception("Quantity  not enough please re-enter");
                                                    }
                                                    else if (0 < am && am < shoesbyid.Amount)
                                                    {
                                                        orders.shoesList[index].Amount = am;
                                                        index++;
                                                        break;
                                                    }
                                                }catch (valueexception e)
                                                {
                                                    Console.Write(e.Message);
                                                    continue;
                                                }catch {
                                                    Console.WriteLine("Dung dep trai");
                                                    Console.Write("Please enter a valid  :");
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                    else if (0 < shoes.Amount && shoes.Amount < shoesbyid.Amount)
                                    {
                                        orders.shoesList.Add(sbl.GetShoesById(shoes.Shoes_id));
                                        orders.shoesList[index].Amount = shoes.Amount;
                                        index++;
                                    }
                                }
                            }
                        }
                    }

                    Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
                    obl.DeleteShoppingCart(2, oredr_iddelete);
                    Console.ReadLine();
                    MenuCustomer();
                }
                else if (choiceorder == "n")
                {
                    MenuCustomer();
                }
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            short mainChoose = 0, imChoose;

            string[]    mainMenu = { "Dang Nhap", "Xem thong tin va dat hang", "Quan li gio hang", "Exit" };
            string[]    imMenu   = { "Get By Item Id", "Get All Items", "Search By Item Name", "Exit" };
            ItemBL      ibl      = new ItemBL();
            CustomerBL  cbl      = new CustomerBL();
            OrderBL     obl      = new OrderBL();
            List <Item> lst;

            do
            {
                mainChoose = Menu(" Nguoi Mua Hang Online", mainMenu);
                switch (mainChoose)
                {
                case 1:
                    do
                    {
                        // if (ibl == null) ibl = new ItemBL();
                        imChoose = Menu("Login", imMenu);
                        switch (imChoose)
                        {
                        case 1:
                            Console.Write("\nInput Item Id: ");
                            int itemId;
                            if (Int32.TryParse(Console.ReadLine(), out itemId))
                            {
                                Item i = ibl.GetItemById(itemId);
                                if (i != null)
                                {
                                    //Console.WriteLine("Item ID: " + i.ItemId);
                                    Console.WriteLine("Item Name: " + i.ItemName);
                                    Console.WriteLine("Item Price: " + i.ItemPrice);
                                    Console.WriteLine("Amount: " + i.Amount);
                                    Console.WriteLine("Item Status: " + i.Status);
                                    Console.WriteLine("Item Description: " + i.Description);
                                }
                                else
                                {
                                    Console.WriteLine("There is no item with id " + itemId);
                                }
                            }
                            else
                            {
                                Console.WriteLine("Your Choose is wrong!");
                            }
                            Console.WriteLine("\n    Press Enter key to back menu...");
                            Console.ReadLine();
                            break;

                        case 2:
                            lst = ibl.GetAll();
                            Console.WriteLine("\nItem Count: " + lst.Count);
                            break;

                        case 3:
                            lst = ibl.GetByName("I");
                            Console.WriteLine("\nItem Count By Name: " + lst.Count);
                            break;
                        }
                    } while (imChoose != imMenu.Length);
                    break;

                case 2:
                    Customer c = new Customer {
                        CustomerName = "Nguyen Thi Nhi", CustomerAddress = "Ha Tay"
                    };
                    Console.WriteLine("Customer ID: " + cbl.AddCustomer(c));
                    break;

                case 3:
                    Order order = new Order();
                    order.OrderCustomer = new Customer {
                        CustmerId = null, CustomerName = "Dao Van Duc", CustomerAddress = "Thai Binh"
                    };
                    order.ItemsList.Add(ibl.GetItemById(2));
                    order.ItemsList[0].Amount = 1;
                    order.ItemsList.Add(ibl.GetItemById(3));
                    order.ItemsList[1].Amount = 2;

                    Console.WriteLine("Create Order: " + (obl.CreateOrder(order) ? "completed!" : "not complete!"));
                    break;
                }
            } while (mainChoose != mainMenu.Length);
        }
Exemplo n.º 12
0
        public static bool Add(Account a, Order o)
        {
            o.OrderTable   = new Table();
            o.OrderAccount = new Account();
            int tableid;

            Console.WriteLine("|| id table  ||      table name     ||     table status     ||");
            foreach (var item in tbl.display())
            {
                if (item.Status == 0)
                {
                    string stt = "empty";
                    Console.WriteLine("||{0,10}||{1,20}||{2,20}||", item.Table_Id, item.TableName, stt);
                }
                else if (item.Status == 1)
                {
                    string stt = "has some one";
                    Console.WriteLine("||{0,10}||{1,20}||{2,20}||", item.Table_Id, item.TableName, stt);
                }
            }
            while (true)
            {
                Console.WriteLine("Input table Id: ");
                tableid = Convert.ToInt32(Console.ReadLine());
                while (tableid == 0 || tableid > 36)
                {
                    Console.Write("Pre-enter: ");
                    try
                    {
                        tableid = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        // Console.WriteLine("error"+ e);
                        // Console.Clear();
                        Console.Write("");
                    }
                }
                var result = tbl.CheckTableById(tableid);

                if (result == true)
                {
                    t = (tbl.GetTableById(tableid));

                    break;
                }

                else
                {
                    Console.WriteLine("Cant find this table or table is not empty!!!");
                    continue;
                }
            }
            o.OrderTable.Table_Id     = tableid;
            o.OrderAccount.Account_Id = a.Account_Id;



            Console.WriteLine("|| item id  ||      Item name     ||     item price     ||");
            foreach (var item in itbl.display())
            {
                Console.WriteLine("||{0,10}||{1,20}||{2,20}||", item.ItemId, item.ItemName, item.ItemPrice);
            }

            while (true)
            {
                Console.WriteLine(" Input Item Id: ");
                int itemid;
                while (!int.TryParse(Console.ReadLine(), out itemid) && itemid < 100 && itemid > 0)
                {
                    Console.WriteLine("Invalid entry. Please enter a number.");
                }

                Console.WriteLine("Input quantity item: ");
                int quantity = Convert.ToInt32(Console.ReadLine());
                while (quantity <= 0 || quantity > 100)
                {
                    Console.WriteLine("Dont try to test my system :)!!");
                    Console.Write("Pre-enter: ");
                    try
                    {
                        quantity = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        // Console.WriteLine("error"+ e);
                        // Console.Clear();
                        Console.Write("");
                    }
                    //  obl.AddItemToOrder(itemid, quantity, o);
                }
                obl.AddItemToOrder(itemid, quantity, o);
                //it = itbl.GetItemById(itemid);
                Console.WriteLine("Do you want to continue Add Item? ");
                string choice2 = Console.ReadLine();
                if (choice2 == "Y" || choice2 == "y")
                {
                    continue;
                }
                else if (choice2 == "N" || choice2 == "n")
                {
                    break;
                }
            }
            Console.WriteLine("Do you want to create order: ");
            char choice3 = Convert.ToChar(Console.ReadLine());

            switch (choice3)
            {
            case 'y':
                Console.WriteLine("Create Order: " + (obl.CreateOrder(o) ? "completed!" : "not complete!"));
                o.ItemsList.Clear();
                Console.WriteLine("Order ID: " + o.OrderId);

                Console.WriteLine("Order Date: " + o.OrderDate);

                foreach (var item in o.ItemsList)
                {
                    Console.WriteLine("Item Name: " + item.ItemName + "  -  " + "Quantity: " + item.Amount + " pecie");
                }
                Console.WriteLine("Order By: " + a.StaffName);
                Console.Write("Press any key to back the menu: ");
                Console.ReadKey();
                break;

            case 'Y':
                Console.WriteLine("Create Order: " + (obl.CreateOrder(o) ? "completed!" : "not complete!"));
                foreach (var item in o.ItemsList)
                {
                    Console.WriteLine("Item Name: " + item.ItemName + "  -  " + "Quantity: " + item.Amount + " pecie");
                }
                Console.WriteLine("Order By: " + a.StaffName);
                Console.Write("Press any key to back the menu: ");
                Console.ReadKey();
                break;

            case 'n':
                Console.Write("Press any key to back the menu: ");
                Console.ReadKey();
                break;

            case 'N':
                Console.Write("Press any key to back the menu: ");
                Console.ReadKey();
                break;

            default:
                Console.Write("Press any key to back the menu: ");
                Console.ReadKey();
                break;
            }
            return(true);
        }
Exemplo n.º 13
0
        public void CreateOrder(Orders or, List <Items> itemsa)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;;
            OrderBL     ordersbl = new OrderBL();

            Console.Write("Enter your note: ");
            string note = Console.ReadLine();

            or.Note = note;
            // string date = DateTime.Now.ToString("dddd, dd MMMM yyyy");
            or.OrderDate = DateTime.Now;
            or.Status    = "Not yet";
            or.Customer  = customer;
            ItemBL itBl = new ItemBL();

            or.Items = new List <Items>();
            or.Items = itemsa;
            bool a = true;
            bool b;

            while (true)
            {
                Console.Clear();
                string check;
                string choice = null;
                Console.WriteLine(row);
                Console.WriteLine("PAY");
                Console.WriteLine(row);
                Console.WriteLine("\n1. Pay by ATM card ");
                Console.WriteLine("2. Pay down ");
                Console.WriteLine("3. Cancel order");

                Console.Write("Enter your select : ");

                choice = Console.ReadLine();
                switch (choice)
                {
                case "1":
                    while (true)
                    {
                        Console.WriteLine("1. Confirm ");
                        Console.WriteLine("2. Back");
                        Console.Write("Enter your selection :");
                        string select = Console.ReadLine();
                        switch (select)
                        {
                        case "1":
                            Console.WriteLine("Press anykey to pay !");
                            Console.ReadKey();
                            if (customer.Money < amount)
                            {
                                Console.WriteLine("Your card does not have enough money ! ");
                                Console.ReadKey();
                                break;
                            }
                            a = ordersbl.CreateOrder(or);
                            items.Clear();
                            Pay(or);
                            break;

                        case "2":

                            break;

                        default:
                            Console.WriteLine("You must enter integer and in the option !");
                            Console.ReadKey();
                            continue;
                        }
                        break;
                    }

                    break;

                case "2":
                    decimal cash;
                    while (true)
                    {
                        Console.WriteLine("The money you must pay : " + amount);
                        Console.Write("Enter amount must pay:");
                        bool c = Decimal.TryParse(Console.ReadLine(), out cash);
                        if (c == false)
                        {
                            Console.WriteLine("You must enter number ! press anykey to continue");
                            Console.ReadKey();
                            continue;
                        }
                        if (cash == amount)
                        {
                            a = ordersbl.CreateOrder(or);
                            items.Clear();
                            Pay(or);
                        }
                        if (cash < amount)
                        {
                            Console.Write("Amout must greater than totle price, do you continue (Y/N)");
                            check = checkYN();
                            if (check == "N")
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (cash > amount)
                        {
                            decimal excessCash = amount - cash;
                            Console.WriteLine("\npay back the excess {0}, press anykey to continue\n", FomatMoney(excessCash));
                            Console.ReadKey();
                            a = ordersbl.CreateOrder(or);
                            items.Clear();
                            Pay(or);
                        }
                    }
                    break;

                case "3":
                    b = ordersbl.DeleteOrder(or.OrderID);
                    Console.WriteLine("Order has been canceled, Press anykey to continue !");
                    Console.ReadKey();
                    MenuAfterLogin();
                    break;

                default:
                    Console.WriteLine("input invalid !");
                    break;
                }
            }
        }
Exemplo n.º 14
0
        private void PlaceOrder()
        {
            Console.WriteLine("This is your current order");
            Console.WriteLine(_currentLocation.ToString());
            Console.WriteLine(_openOrder.ToString());
            bool repeat = true;

            do
            {
                Console.WriteLine("Would you like to place the order? [y/n]");
                string input = Console.ReadLine().ToLower();
                if (input == "y")
                {
                    repeat = false;
                    using (var log = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().WriteTo.File("../logs/logs.txt", rollingInterval: RollingInterval.Day).CreateLogger())
                    {
                        try
                        {
                            //first, close the order
                            _openOrder.Closed = true;

                            //and then, create the order
                            int createdId = _orderBL.CreateOrder(_openOrder).Id;

                            //Now we need to create line items associated to the order
                            foreach (LineItem item in _openOrder.LineItems)
                            {
                                item.OrderId = createdId;
                                _orderBL.CreateLineItem(item);
                            }

                            //update the store's inventory after the successful placement of the order by getting all the inventory of the location of the order
                            List <Inventory> allInventory = _locationBL.GetLocationInventory(_currentLocation.Id);

                            //and then update the inventory of the order and persist it to the DB
                            foreach (LineItem lineItem in _openOrder.LineItems)
                            {
                                Inventory boughtItem = allInventory.Find(invenItem => invenItem.Product.Id == lineItem.Product.Id);
                                boughtItem.Quantity -= lineItem.Quantity;
                                _locationBL.UpdateInventoryItem(boughtItem);
                            }
                            Console.WriteLine("Order placed successfully!");
                            _openOrder = new Order {
                                CustomerId = _currentCustomer.Id,
                                LocationId = _currentLocation.Id,
                                LineItems  = new List <LineItem>()
                            };
                        }
                        catch (Exception ex)
                        {
                            log.Warning(ex.Message);
                        }
                    }
                }
                else if (input == "n")
                {
                    repeat = false;
                    return;
                }
                else
                {
                    Console.WriteLine("I don't understand your input, please try again");
                }
            } while(repeat);
        }
Exemplo n.º 15
0
        public void ShowCart()
        {
            while (true)
            {
                if (File.Exists("shoppingcart" + cusAll.UserName + ".dat"))
                {
                    List <Items> itemsa = null;
                    Orders       or     = new Orders();
                    decimal      amount = 0;
                    try
                    {
                        FileStream   fs = new FileStream("shoppingcart" + cusAll.UserName + ".dat", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                        BinaryReader br = new BinaryReader(fs);
                        string       a  = br.ReadString();

                        itemsa = JsonConvert.DeserializeObject <List <Items> >(a);

                        br.Close();
                        fs.Close();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                    var table = new ConsoleTable("ID", "ITEM NAME");
                    foreach (var itema in itemsa)
                    {
                        table.AddRow(itema.ItemID, itema.ItemName);
                        amount += itema.ItemPrice;
                    }
                    table.Write();
                    string orde;
                    Console.Write("Do you want create order ? (Y/N):");
                    orde = checkYN();
                    if (orde == "Y")
                    {
                        Console.Write("Enter your note: ");
                        string   note = Console.ReadLine();
                        DateTime date = DateTime.Now;
                        or.OrderDate  = date;
                        or.Status     = "Not yet";
                        or.Amount     = amount;
                        or.CustomerID = cusAll;
                        foreach (var item in itemsa)
                        {
                            or.Items = new List <Items>();
                            or.Items.Add(itBl.GetItemByItemID(or.ItemID));
                            // ordersbl.CreateOrder(or);
                        }
                        bool a = true;
                        try
                        {
                            a = ordersbl.CreateOrder(or);
                        }
                        catch (System.Exception)
                        {
                            a = false;
                            Console.WriteLine("\n ☹  Create order faild , press anykey to continue !\n");
                            Console.ReadKey();
                            break;
                        }
                        if (a == true)
                        {
                            Console.WriteLine("Create order success ! ");
                            try
                            {
                                // Check if file exists with its full path
                                if (File.Exists(Path.Combine("shoppingcart" + cusAll.UserName + ".dat")))
                                {
                                    // If file found, delete it
                                    File.Delete(Path.Combine("shoppingcart" + cusAll.UserName + ".dat"));
                                }
                                else
                                {
                                    Console.WriteLine("Cart not found");
                                }
                            }
                            catch (IOException ioExp)
                            {
                                Console.WriteLine(ioExp.Message);
                            }
                        }
                        else
                        {
                            Console.WriteLine("\n ☹  Create order faild , press anykey to continue !\n");
                            Console.ReadKey();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("\nNo shopping cart yet , press anykey to continue !\n");
                    Console.ReadKey();
                    break;
                }
            }
        }
Exemplo n.º 16
0
        public void Displaylistshoes()
        {
            Console.Clear();
            ShoesBL sbl   = new ShoesBL();
            var     lists = sbl.GetAllShoes();
            string  line  = ("===================================================================================================================\n");

            Console.WriteLine(line);
            Console.Write(" Shoes_Id  |  Shoes_Name           |    Price         |  Size  |      Style             |   Color        | Amount |\n");
            Console.WriteLine(line);
            foreach (var Shoes in lists)
            {
                Console.WriteLine("{0,-15}{1,-25}{2,-17}{3,-10}{4,-24}{5,-18}{6} ", Shoes.Shoes_id, Shoes.Shoes_name, Shoes.Price, Shoes.Size, Shoes.Style, Shoes.Color, Shoes.Amount);
            }
            Console.WriteLine(line);
            Console.Write("Do you want to see product details?(y/n)");
            string choice = Console.ReadLine();

            if (choice == "y")
            {
                Console.Write("Input  Shoes_ID: ");
                while (true)
                {
                    try
                    {
                        sh_id = Convert.ToInt32(Console.ReadLine());
                        var shoes = sbl.GetShoesById(sh_id);
                        if (shoes == null)
                        {
                            throw new valueexception("Not find Shoes_ID,please re-enter : ");
                        }
                        else if (shoes != null)
                        {
                            Console.Clear();
                            Console.WriteLine("          Product Information        ");
                            Console.WriteLine("-ID                : {0}", shoes.Shoes_id);
                            Console.WriteLine("-Name              : {0}", shoes.Shoes_name);
                            Console.WriteLine("-Size              : {0}", shoes.Size);
                            Console.WriteLine("-Amount            : {0}", shoes.Amount);
                            Console.WriteLine("-Price             : {0}dong", shoes.Price);
                            Console.WriteLine("-Color             : {0}", shoes.Color);
                            Console.WriteLine("-Material          : {0}", shoes.Material);
                            Console.WriteLine("-Manufacture       : {0}", shoes.Manufacture);
                            Console.WriteLine("-Trademark name    : {0}", shoes.TM.Name);
                            Console.WriteLine("-Trademark Origin  : {0}", shoes.TM.Origin);
                            while (true)
                            {
                                short    mainChoose = 0;
                                string[] mainMenu   = { "Add in shopping cart", "Order now ", "Return shoes list" };
                                while (mainChoose != mainMenu.Length)
                                {
                                    mainChoose = Menu2("You want to add to your shopping cart, buy or return to the shoes list? ", mainMenu);
                                    switch (mainChoose)
                                    {
                                    case 1:
                                        Addshoppingcart();
                                        break;

                                    case  2:
                                        OrderBL obl    = new OrderBL();
                                        Orders  orders = new Orders();
                                        orders.shoesList    = new List <Shoes>();
                                        orders.Order_status = 1;
                                        orders.user         = new User();
                                        orders.user.User_id = id;
                                        orders.shoesList.Add(sbl.GetShoesById(sh_id));
                                        var getshoes = sbl.GetShoesById(sh_id);
                                        while (true)
                                        {
                                            try
                                            {
                                                Console.Write("Input  Amount: ");
                                                int amount1 = Convert.ToInt32(Console.ReadLine());
                                                if ((amount1 > getshoes.Amount && getshoes.Amount == 0) || (amount1 == getshoes.Amount && getshoes.Amount == 0))
                                                {
                                                    Console.WriteLine("Quantity no longer please put another product .. !");
                                                    Console.ReadLine();
                                                    Displaylistshoes();
                                                }
                                                if (amount1 > getshoes.Amount && getshoes.Amount > 0)
                                                {
                                                    Console.WriteLine("Quantity in stock : {0}", getshoes.Amount);
                                                    throw (new valueexception("Not enough quantity , please re-enter: "));
                                                }
                                                else if (0 < amount1 || amount1 <= getshoes.Amount)
                                                {
                                                    orders.shoesList[0].Amount = amount1;
                                                    break;
                                                }
                                            }
                                            catch (valueexception e)
                                            {
                                                Console.Write(e.Message);
                                                continue;
                                            }
                                            catch
                                            {
                                                Console.Write("Please enter a valid  :");
                                                continue;
                                            }
                                            break;
                                        }
                                        Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
                                        Console.ReadLine();
                                        Displaylistshoes();
                                        break;

                                    case 3:
                                        Displaylistshoes();
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (valueexception e)
                    {
                        Console.Write(e.Message);
                        continue;
                    }
                    catch
                    {
                        Console.WriteLine("FUCK1");
                        Console.Write("Please enter a valid value :");
                        continue;
                    }
                    break;
                }
            }
            else if (choice == "n")
            {
                MenuCustomer();
            }
        }
Exemplo n.º 17
0
 public void Create_test()
 {
     Assert.False(obl.CreateOrder(new Orders()));
 }
Exemplo n.º 18
0
        public void Start()
        {
            bool   firstrepeat = true;
            string custName;
            string custPhone;
            string custAddress;

            Console.WriteLine("Please enter your info");
            Console.WriteLine("Name:");
            custName = Console.ReadLine();
            Console.WriteLine("Phone Number:");
            custPhone = Console.ReadLine();
            Console.WriteLine("Address:");
            custAddress = Console.ReadLine();
            if (!(_custBL.CheckForUser(custName, custPhone, custAddress)))
            {
                _custBL.CreateUser(custName, custPhone, custAddress);
            }
            AppUser user1 = new AppUser(custName, custAddress, custPhone);

            Console.WriteLine("Welcome!  which location would you like to order from?");
            Console.WriteLine("[0] Downtown");
            Console.WriteLine("[1] Suburbs");
            Console.WriteLine("[2] Exit to main menu");
            List <Products> selectedProducts = new List <Products>();

            while (firstrepeat == true)
            {
                string input = Console.ReadLine();
                if (input == "0")
                {
                    bool repeat = true;
                    firstrepeat = false;
                    Location downtown = new Location();
                    downtown.Address = "77 Market Street, St. Louis, MO, 63118";

                    Console.WriteLine("Welcome to our Downtown location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
                    do
                    {
                        Console.WriteLine(_invBL.ShowInventory(downtown));
                        List <Products> fullprods = _orderBL.PrepProducts();
                        Products        ChosenProduct;
                        Console.WriteLine("Welcome to our Downtown location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
                        string Search    = Console.ReadLine();
                        bool   listCheck = true;
                        if (Search == "Exit")
                        {
                            Order userOrder = _orderBL.CreateOrder(selectedProducts, user1, downtown);
                            repeat      = false;
                            firstrepeat = false;
                            Console.WriteLine("Here is the reciept for your order. Thank you for shopping with us!");
                            Console.WriteLine(userOrder.ToString());
                            Console.ReadLine();
                            break;
                        }
                        else
                        {
                            foreach (Products p in fullprods)
                            {
                                listCheck = fullprods.Any(p => p.ItemName == Search);
                            }
                            if (listCheck)
                            {
                                ChosenProduct = fullprods.FirstOrDefault(p => p.ItemName == Search);
                                selectedProducts.Add(ChosenProduct);
                                _invBL.TakeFrom(downtown, ChosenProduct);
                            }
                            else
                            {
                                Console.WriteLine("Please select an item that is listed");
                            }
                            foreach (Products p in selectedProducts)
                            {
                                Console.WriteLine($"Current Order {p.ItemName}");
                            }
                        }
                    }while (repeat);
                }
                else if (input == "1")
                {
                    bool repeat = true;
                    firstrepeat = false;
                    Location suburbs = new Location();
                    suburbs.Address = "1 Lockwood Ave, Webster Groves, MO 63119";

                    Console.WriteLine("Welcome to our Downtown location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
                    do
                    {
                        Console.WriteLine(_invBL.ShowInventory(suburbs));
                        List <Products> fullprods = _orderBL.PrepProducts();
                        Products        ChosenProduct;
                        Console.WriteLine("Welcome to our Downtown location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
                        string Search    = Console.ReadLine();
                        bool   listCheck = true;
                        if (Search == "Exit")
                        {
                            Order userOrder = _orderBL.CreateOrder(selectedProducts, user1, suburbs);
                            repeat      = false;
                            firstrepeat = false;
                            Console.WriteLine("Here is the reciept for your order. Thank you for shopping with us!");
                            Console.WriteLine(userOrder.ToString());
                            Console.ReadLine();
                            break;
                        }
                        else
                        {
                            foreach (Products p in fullprods)
                            {
                                listCheck = fullprods.Any(p => p.ItemName == Search);
                            }
                            if (listCheck)
                            {
                                ChosenProduct = fullprods.FirstOrDefault(p => p.ItemName == Search);
                                selectedProducts.Add(ChosenProduct);
                                _invBL.TakeFrom(suburbs, ChosenProduct);
                            }
                            else
                            {
                                Console.WriteLine("Please select an item that is listed");
                            }
                            foreach (Products p in selectedProducts)
                            {
                                Console.WriteLine($"Current Order {p.ItemName}");
                            }
                        }
                    }while (repeat);
                }
                else
                {
                    Console.WriteLine("Please select a valid option");
                }
            }


            /*case "1":
             * bool repeat2 = true;
             * Location suburbs = new Location();
             * suburbs.Address = "1 Lockwood Ave, Webster Groves, MO 63119";
             * Console.WriteLine("Welcome to our suburbia location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
             *  do
             *  {
             *
             *     Console.WriteLine(_invBL.ShowInventory(suburbs));
             *     List<Products> fullprods = _orderBL.PrepProducts();
             *     Console.WriteLine("Welcome to our Suburbia location.  Please select from the following inventory by typing in the name of the product. Type exit when you wish to check out.");
             *     string Search = Console.ReadLine();
             *     if(Search == "Exit" || Search == "exit"){
             *         Order userOrder = _orderBL.CreateOrder(selectedProducts, user1, suburbs);
             *         repeat2 = false;
             *     }
             *         Products ChosenProduct =  fullprods.First(p => p.ItemName == Search);
             *      if(ChosenProduct != null) {selectedProducts.Add(ChosenProduct);
             *      foreach (Products p in selectedProducts){
             *          Console.WriteLine(p.ItemName);
             *      }
             *      {
             *
             *      }
             *     }else{
             *         Console.WriteLine("Please select an item that is listed");
             *     }
             *
             *
             *
             *     _invBL.TakeFrom(suburbs, ChosenProduct);
             *
             *  } while (repeat2);
             * break;
             * case "2":
             * Console.WriteLine("Have a nice day!");
             * break;*/
            Console.WriteLine();
        }
Exemplo n.º 19
0
        public void Purchase(User user)  // thanh toán sản phẩm
        {
            Order order = new Order();

            order.ListItem = new List <Item> ();
            Console.Write("Bạn có muốn thanh toán không ?(C/K): ");
            string choose1;

            while (true)
            {
                choose1 = Console.ReadLine().ToUpper();
                if (choose1 != "C" && choose1 != "K")
                {
                    Console.WriteLine("Bạn đã nhập sai, hãy nhập lại!   ");
                    Console.WriteLine("Bạn có muốn thanh toán không ?(C/K): ");
                    continue;
                }
                else
                {
                    break;
                }
            }
            switch (choose1)
            {
            case "C":
                break;

            case "K":
                orderConsole.ShowCarts(user);
                break;
            }
            Console.Clear();
            try {
                StreamReader r = new StreamReader("order" + user.user_id + ".json");
                r.Close();
            } catch (System.Exception) {
                Console.WriteLine("Mất kết nối dữ liệu!");
                Console.Write("Bấm phím bất kì để tiếp tục ");
                Console.ReadKey();
                m.MainMenu();
            }
            using (StreamReader r = new StreamReader("order" + user.user_id + ".json")) {
                double price = 0;
                var    json  = r.ReadToEnd();
                r.Close();
                var ListOrder = JsonConvert.DeserializeObject <Order> (json);
                Console.Clear();
                Console.WriteLine("|================================================|");
                Console.WriteLine("|---------------| CHI TIẾT ĐƠN HÀNG |------------|");
                Console.WriteLine("|================================================|");
                Console.WriteLine("|{0,-25}|{1,-20}  |", "Tên sản phẩm", "Giá sản phẩm");
                Console.WriteLine("|------------------------------------------------|");
                foreach (var orders in ListOrder.ListItem)
                {
                    string format = string.Format($"|{orders.item_name,-25}|{FormatAndValid.FormatCurrency(orders.item_price),-15}       |");
                    Console.WriteLine(format);
                    Console.WriteLine("|================================================|");
                    price += orders.item_price;    // tính tổng giá của tất cả sản phẩm có trong giỏ hàng
                    if (user.user_balance < price) // nếu tiền ko đủ thì nạp hoặc trở lại
                    {
                        Console.WriteLine("Tài khoản của quý khách không đủ để thực hiện giao dịch này !");
                        Console.Write("Bạn có muốn nạp thêm tiền vào tài khoản không?(C/K): ");
                        string choose;
                        while (true)
                        {
                            choose = Console.ReadLine().ToUpper();
                            if (choose != "C" && choose != "K")
                            {
                                Console.WriteLine("Bạn đã nhập sai, hãy nhập lại!");
                                Console.Write("Bạn có muốn nạp thêm tiền vào tài khoản không?(C/K)?: ");
                                continue;
                            }
                            else
                            {
                                break;
                            }
                        }
                        switch (choose)
                        {
                        case "C":
                            u.AddFund(user);
                            break;

                        case "K":
                            orderConsole.ShowCarts(user);
                            break;
                        }
                    }
                    else   // trừ tiền trong bảng order
                    {
                        user.user_balance = user.user_balance - price;
                    }

                    order.ListItem.Add(orders);  // thêm order vào list
                }
                order.user     = user;
                order.order_id = ListOrder.order_id;
            }
            if (orderBL.CreateOrder(order) == true)  // nếu mua hàng thành công thì xóa file chưa thì vẫn lưu trong file
            {
                Console.WriteLine("Mua hàng thành công!\nẤn phím bất kì để tiếp tục! ");
                File.Delete("order" + user.user_id + ".json");
                Console.ReadKey();
                ms.menuShop(user);
            }
            else
            {
                Console.WriteLine("Mua hàng Không thành công, đã có lỗi xảy ra \nẤn phím bất kì để quay về Trang chủ!");
                Console.ReadKey();
                ms.menuShop(user);
            }
        }
Exemplo n.º 20
0
 public IActionResult Create(ShoppingBOL.Order order)
 {
     orderBl.CreateOrder(order);
     orderBl.SaveChanges();
     return(RedirectToAction("Create", "Order"));
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            short mainChoose = 0, imChoose;

            string[]    mainMenu = { "Item Management", "Add Customer (using stored procedure)", "Create Order (using Transaction)", "Exit" };
            string[]    imMenu   = { "Get By Item Id", "Get All Items", "Search By Item Name", "Exit" };
            ItemBL      ibl      = new ItemBL();
            CustomerBL  cbl      = new CustomerBL();
            OrderBL     obl      = new OrderBL();
            List <Item> lst;

            do
            {
                mainChoose = Menu(" Order Management System - OMS", mainMenu);
                switch (mainChoose)
                {
                case 1:
                    do
                    {
                        // if (ibl == null) ibl = new ItemBL();
                        imChoose = Menu("Item Management", imMenu);
                        switch (imChoose)
                        {
                        case 1:
                            Console.Write("\nInput Item Id: ");
                            int itemId;
                            if (Int32.TryParse(Console.ReadLine(), out itemId))
                            {
                                Item i = ibl.GetItemById(itemId);
                                if (i != null)
                                {
                                    //Console.WriteLine("Item ID: " + i.ItemId);
                                    Console.WriteLine("Item Name: " + i.ItemName);
                                    Console.WriteLine("Item Price: " + i.ItemPrice);
                                    Console.WriteLine("Amount: " + i.Amount);
                                    Console.WriteLine("Item Status: " + i.Status);
                                    Console.WriteLine("Item Description: " + i.Description);
                                }
                                else
                                {
                                    Console.WriteLine("There is no item with id " + itemId);
                                }
                            }
                            else
                            {
                                Console.WriteLine("Your Choose is wrong!");
                            }
                            Console.WriteLine("\n    Press Enter key to back menu...");
                            Console.ReadLine();
                            break;

                        case 2:
                            lst = ibl.GetAll();
                            Console.WriteLine("\nItem Count: " + lst.Count);
                            break;

                        case 3:
                            lst = ibl.GetByName("I");
                            Console.WriteLine("\nItem Count By Name: " + lst.Count);
                            break;
                        }
                    } while (imChoose != imMenu.Length);
                    break;

                case 2:
                    Customer c = new Customer {
                        CustomerName = "Nguyen Thi Nhi", CustomerAddress = "Ha Tay"
                    };
                    Console.WriteLine("Customer ID: " + cbl.AddCustomer(c));
                    break;

                case 3:
                    Order order = new Order();
                    //new customer
                    //order.OrderCustomer = new Customer { CustmerId = null, CustomerName = "Nguyen Xuan Sinh", CustomerAddress = "Hanoi" };

                    //exists customer
                    order.OrderCustomer = new Customer {
                        CustmerId = 1, CustomerName = "Nguyen Xuan Sinh", CustomerAddress = "Hanoi"
                    };

                    order.ItemsList.Add(ibl.GetItemById(2));
                    order.ItemsList[0].Amount = 1;
                    order.ItemsList.Add(ibl.GetItemById(3));
                    order.ItemsList[1].Amount = 2;
                    Console.WriteLine("Create Order: " + (obl.CreateOrder(order) ? "completed!" : "not complete!"));
                    break;
                }
            } while (mainChoose != mainMenu.Length);
        }
Exemplo n.º 22
0
        public void ShoppingCart()
        {
            var     Or_us = obl.GetAllOrderByIDUser(id);
            decimal a;
            string  money1 = "0";
            int     b      = Or_us.FindIndex(x => x.Order_status == 0);

            if (b == -1)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The list is empty, no invoices have been generated!");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.ReadLine();
            }
            else if (b != -1)
            {
                string line = "============================================================================================";
                Console.WriteLine(line);
                foreach (var orders in Or_us)
                {
                    a = 0;
                    if (orders.Order_status == 0)
                    {
                        var orderdetail = obl.GetOrderDetailsByID(orders.Order_id);
                        Console.Clear();
                        Console.WriteLine("SHOES STORE");
                        Console.WriteLine("          Shopping Cart        ");
                        Console.WriteLine(line);
                        Console.Write(" Product name      |  Unitprice          |  Amount          |  Size     |     Total          \n");
                        foreach (var order in orderdetail.shoesList)
                        {
                            Decimal c      = order.Price * order.Amount;
                            string  money  = String.Format("{0:0,0}vnđ", c);
                            string  money2 = String.Format("{0:0,0}vnđ", order.Price);
                            Console.WriteLine("{0,-20} {1,-26} {2,-15} {3,-10} {4}", order.Shoes_name, money2, order.Amount, order.Size, money);

                            a     += c;
                            money1 = String.Format("{0:0,0.00}vnđ", a);
                        }
                        Console.WriteLine(line);
                        Console.WriteLine("-The total amount payable                                                  {0}", money1);
                    }
                }
                Console.WriteLine(line);
                Console.Write("Do you want to create  order ?(y/n)");
                string choiceorder = Console.ReadLine();
                if (choiceorder == "y")
                {
                    Orders orders = new Orders();
                    orders.shoesList    = new List <Shoes>();
                    orders.Order_status = 1;
                    int indexsp = 0;
                    orders.user         = new User();
                    orders.user.User_id = id;
                    foreach (var order in Or_us)
                    {
                        if (order.user.User_id == id)
                        {
                            if (order.Order_status == 0)
                            {
                                oredr_iddelete = order.Order_id;
                                var detail = obl.GetOrderDetailsByID(order.Order_id);
                                foreach (var shoes in detail.shoesList)
                                {
                                    var shoesbyid = sbl.GetShoesById(shoes.Shoes_id);
                                    if (shoes.Amount > shoesbyid.Amount)
                                    {
                                        Console.WriteLine(" Insufficient quantity Would you like to cancel this product? (y/n)", shoesbyid.Amount);
                                        char c = Convert.ToChar(Console.ReadLine());
                                        if (c == 'y')
                                        {
                                            obl.Delete(shoes.Amount, order.Order_id);
                                            break;
                                        }
                                        else if (c == 'n')
                                        {
                                            orders.shoesList.Add(sbl.GetShoesById(shoes.Shoes_id));
                                            while (true)
                                            {
                                                Console.WriteLine("Please re-enter the product number: ");
                                                try{
                                                    int am = Convert.ToInt32(Console.ReadLine());
                                                    if ((am > shoesbyid.Amount && shoesbyid.Amount == 0) || (am == shoesbyid.Amount && shoesbyid.Amount == 0))
                                                    {
                                                        Console.WriteLine("Quantity no longer please put another product .. !");
                                                        Console.ReadLine();
                                                        break;
                                                    }
                                                    else if (am > shoesbyid.Amount)
                                                    {
                                                        throw new valueexception("Quantity  not enough please re-enter");
                                                    }
                                                    else if (0 < am && am < shoesbyid.Amount)
                                                    {
                                                        orders.shoesList[indexsp].Amount = am;
                                                        indexsp++;
                                                        break;
                                                    }
                                                }catch (valueexception e)
                                                {
                                                    Console.Write(e.Message);
                                                    continue;
                                                }catch {
                                                    Console.Write("Please enter a valid  :");
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                    else if (0 < shoes.Amount && shoes.Amount < shoesbyid.Amount)
                                    {
                                        orders.shoesList.Add(sbl.GetShoesById(shoes.Shoes_id));
                                        orders.shoesList[indexsp].Amount = shoes.Amount;
                                        indexsp++;
                                    }
                                }
                            }
                        }
                    }
                    Console.Write("Do you want to use the number of phone and current address to get unsigned ? :");
                    string chon = Console.ReadLine();
                    if (chon == "n")
                    {
                        Console.WriteLine("Please enter  phone number and address! ");
                        while (true)
                        {
                            Console.Write("-Enter recipient address :");
                            orders.Address = Console.ReadLine();
                            if (orders.Address != " ")
                            {
                                break;
                            }
                        }
                        Console.Write("-Enter the recipient's phone number :");
                        while (true)
                        {
                            orders.phone = Console.ReadLine();
                            if (IsValidString(orders.phone) == true)
                            {
                                break;
                            }
                            else
                            {
                                Console.Write("Please re-enter the recipient's phone number correctly : ");
                            }
                        }
                    }
                    else
                    {
                        var userdt = ubl.GetUserByid(id);
                        orders.Address = userdt.Address;
                        orders.phone   = userdt.Phone;
                    }
                    Console.WriteLine("Create Order: " + (obl.CreateOrder(orders) ? "completed!" : "not complete!"));
                    obl.DeleteShoppingCart(0, oredr_iddelete);
                    Console.ReadLine();
                    MenuCustomer();
                }
                else if (choiceorder == "n")
                {
                    MenuCustomer();
                }
            }
        }