public ActionResult OrderList()
        {
            OrderBusinessLayer OBL    = new OrderBusinessLayer();
            List <PlaceOrder>  orders = OBL.Orders.ToList <PlaceOrder>();

            return(View(orders));
        }
        /// <summary>
        /// Represents a method for cancel order
        /// </summary>
        static void CancelOrder()
        {
            Console.WriteLine("Enter OrderId");
            int orderId = int.Parse(Console.ReadLine());
            OrderBusinessLayer orderBusiness = new OrderBusinessLayer();

            orderBusiness.CancelOrderDetails(orderId);
        }
        public ActionResult placeOrder(int id, int quantity, int price)
        {
            OrderBusinessLayer OBL = new OrderBusinessLayer();
            PlaceOrder         ord = new PlaceOrder();

            ord.OrderID  = id;
            ord.Quantity = quantity;
            ord.Price    = price;

            OBL.addOrder(ord);

            return(View());
        }
        /// <summary>
        /// Represents method for updating the order details
        /// </summary>
        static void UpdateOrderDetails()
        {
            OrderBusinessLayer orderBusiness = new OrderBusinessLayer();
            int choice = 0;

            do
            {
                Console.WriteLine("Choose the following details which do you want to update");
                Console.WriteLine("1.Product Details");
                Console.WriteLine("2.Quantity");
                Console.WriteLine("3.Customer Details");
                Console.WriteLine("4.Exit");

                Console.WriteLine("Enter Choice:");
                choice = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter OrderID");
                int orderId = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:


                    Console.WriteLine("Enter ProductID");
                    string ProductId = Console.ReadLine();
                    orderBusiness.UpdateProductDetails(orderId, ProductId);;
                    break;

                case 2:
                    Console.WriteLine("Enter Quantity");
                    int quantity = int.Parse(Console.ReadLine());
                    orderBusiness.UpdateQuantity(orderId, quantity);
                    break;

                case 3:
                    Console.WriteLine("Enter AddressID");
                    string addressID = Console.ReadLine();
                    orderBusiness.UpdateCustomerAddressDetails(orderId, addressID);
                    break;

                case 4:
                    Console.WriteLine("Enter CustomerID");
                    int customerId = int.Parse(Console.ReadLine());
                    orderBusiness.UpdateCustomerAddressDetails(orderId, customerId);
                    break;

                case 5:
                    Console.WriteLine("Exit"); break;
                }
            } while (choice != 4);
        }
        /// <summary>
        /// Represents method to view the Order Details
        /// </summary>

        static void ViewOrderDetails()
        {
            OrderBusinessLayer orderBusiness = new OrderBusinessLayer();

            Console.WriteLine("Enter CustomerID");
            int CustomerID = int.Parse(Console.ReadLine());
            //List<OrderProduct> orderProducts = orderBusiness.GetOrderDetailsByCustomerID(CustomerID);

            /* foreach (var order in orders)
             * {
             *   Console.WriteLine("ProductId:" + order.ProductId);
             *   Console.WriteLine("CustomerAddressId:" + order.CustomerAddressId);
             *   Console.WriteLine("TotalPrice:" + order.TotalPrice);
             *   Console.WriteLine("Quantity;" + order.Quantity);
             * }*/
        }
        /// <summary>
        /// Method for adding Ordrdetails to List
        /// </summary>

        public void PlaceOrder()
        {
            try
            {
                OrderProduct       order      = new OrderProduct();
                OrderBusinessLayer orderLayer = new OrderBusinessLayer();

                //Calling the method from BusinessLogicLayer to display the details
                Console.WriteLine("============Product Details==========");
                Console.WriteLine("Enter ProductID to select Products that you want to order");
                order.ProductID = Console.ReadLine();
                Console.WriteLine("Enter Quantity");
                int     quantity = int.Parse(Console.ReadLine());
                Product p        = orderLayer.ProductDetails(order.ProductId);
                order.TotalPrice += p.CostPrice * quantity;
                Console.WriteLine("================AddressDetails of customer==========");
                Console.WriteLine("Enter your CustomerId to Choose your Address");
                int      CustomerID      = int.Parse(Console.ReadLine());
                Customer customerAddress = orderLayer.GetOrderDetailsByCustomerID(CustomerID);
                order.CustomerAddressId = CustomerID;

                Console.WriteLine("Price for selected Products is:" + order.TotalPrice);
                Console.WriteLine("Enter 1 if you want to Confirm Your Order");
                int i = int.Parse(Console.ReadLine());
                if (i == 1)
                {
                    Console.WriteLine("Your OrderID is:" + orderLayer.OrderID());
                    //orderLayer.AddOrderDetails(order);
                }
                else
                {
                    Console.WriteLine("You didn't confirm your orders,please Try again");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 7
0
        public void generateOrderIntruction(Order order)
        {
            List <String>        instruction    = new List <string>();
            JavaScriptSerializer jsonSerialiser = new JavaScriptSerializer();
            WarehouseDBEntities  wdb            = new WarehouseDBEntities();
            OrderBusinessLayer   wbl            = new OrderBusinessLayer();
            string instructionString            = "";

            /**
             *
             * Go to Shelf "shelf id" and pick "item name" from slots "start slot" to "end slot" and send them to depot
             **/
            foreach (var inst in dispatchInstructions.Distinct())
            {
                Shelf shelf = wdb.Shelves.Find(inst.shelfid);

                string[] shelveName = shelf.shelfName.Split('s');
                string   shelves    = "s" + shelveName[1];
                shelfRetrieval.Add(shelves);

                instructionString = "Go to shelf " + shelves + " and pick " + inst.itemname + " from slots " + inst.startslot + " to " + inst.endslot + " and send them to depot";
                instruction.Add(instructionString);



                Slotting s = new Slotting();

                List <ShelfItems> shelfItems     = s.covert_to_object(shelf.shelfItems);
                List <ShelfItems> copyShelfItems = new List <ShelfItems>();
                copyShelfItems.AddRange(shelfItems);

                bool with = false;
                int  i    = 0;
                foreach (ShelfItems shelve in shelfItems)
                {
                    if (shelve.slot_id == inst.startslot || with == true)
                    {
                        with = true;
                        copyShelfItems[i].item_id     = -1;
                        copyShelfItems[i].status      = 0;
                        copyShelfItems[i].item_name   = "";
                        copyShelfItems[i].expiry_date = "";


                        if (shelve.slot_id == inst.endslot)
                        {
                            with = false;
                        }
                    }
                    i++;
                }


                string updatedString = jsonSerialiser.Serialize(copyShelfItems);
                wbl.updateShelf(inst.shelfid, updatedString);
            }



            string json = jsonSerialiser.Serialize(instruction);

            int maxDispatchId = 1;

            try
            {
                maxDispatchId = wdb.Orders.Max(a => a.dispatchNo).Value + 1;
            }
            catch (Exception ex)
            {
                maxDispatchId = 1;
            }


            wbl.updateOrder(order.orderId, json, maxDispatchId);
            WarehouseDBEntities wde = new WarehouseDBEntities();
            Order orders            = wde.Orders.Find(order.orderId);

            orders.shelfRetrieval   = jsonSerialiser.Serialize(shelfRetrieval.Distinct().ToList());
            wde.Entry(orders).State = System.Data.Entity.EntityState.Modified;
            wde.SaveChanges();
        }