Ejemplo n.º 1
0
 public List <CustOrderHist> CustOrderHist(string customerID)
 {
     return(orderHistoryRepository.GetAll(customerID));
 }
Ejemplo n.º 2
0
        public ActionResult CompleteOrder()
        {
            //finalize the order from cart

            //shopping cart data
            int Locationid = int.Parse(HttpContext.Request.Cookies["LocationID"]);
            int customerid = int.Parse(HttpContext.Request.Cookies["CustomerID"]);
            int ProductID1 = int.Parse(HttpContext.Request.Cookies["ProID1"]);
            int ProductID2 = int.Parse(HttpContext.Request.Cookies["ProID2"]);
            int ProductID3 = int.Parse(HttpContext.Request.Cookies["ProID3"]);
            int ProductID4 = int.Parse(HttpContext.Request.Cookies["ProID4"]);
            int ProductID5 = int.Parse(HttpContext.Request.Cookies["ProID5"]);
            int Amount1    = int.Parse(HttpContext.Request.Cookies["PA1"]);
            int Amount2    = int.Parse(HttpContext.Request.Cookies["PA2"]);
            int Amount3    = int.Parse(HttpContext.Request.Cookies["PA3"]);
            int Amount4    = int.Parse(HttpContext.Request.Cookies["PA4"]);
            int Amount5    = int.Parse(HttpContext.Request.Cookies["PA5"]);

            //New Order History
            OrderHistory orderHistory = new OrderHistory
            {
                LocationId = Locationid,
                CustomerId = customerid
            };

            _orderhistoryRepo.Create(orderHistory);


            //The new Order ID
            int orderid = _orderhistoryRepo.GetAll().Count();

            //note to self, compress next step into dynamic
            //new orders
            if (ProductID1 == 1)
            {
                Inventory inventory1 = new Inventory
                {
                    LocationId = Locationid,
                    ProductId  = ProductID1,
                    Amount     = Amount1
                };

                Orders orders1 = new Orders
                {
                    OrderID   = orderid,
                    ProductID = ProductID1,
                    Amount    = Amount1
                };
                //finalize
                _inventoryRepo.Update(inventory1);
                _ordersRepo.Create(orders1);
            }
            if (ProductID2 == 2)
            {
                Inventory inventory2 = new Inventory
                {
                    LocationId = Locationid,
                    ProductId  = ProductID2,
                    Amount     = Amount2
                };

                Orders orders2 = new Orders
                {
                    OrderID   = orderid,
                    ProductID = ProductID2,
                    Amount    = Amount2
                };
                //finalize
                _inventoryRepo.Update(inventory2);
                _ordersRepo.Create(orders2);
            }
            if (ProductID3 == 3)
            {
                Inventory inventory3 = new Inventory
                {
                    LocationId = Locationid,
                    ProductId  = ProductID3,
                    Amount     = Amount3
                };

                Orders orders3 = new Orders
                {
                    OrderID   = orderid,
                    ProductID = ProductID3,
                    Amount    = Amount3
                };
                //finalize
                _inventoryRepo.Update(inventory3);
                _ordersRepo.Create(orders3);
            }
            if (ProductID4 == 4)
            {
                Inventory inventory4 = new Inventory
                {
                    LocationId = Locationid,
                    ProductId  = ProductID4,
                    Amount     = Amount4
                };

                Orders orders4 = new Orders
                {
                    OrderID   = orderid,
                    ProductID = ProductID4,
                    Amount    = Amount4
                };
                //finalize
                _inventoryRepo.Update(inventory4);
                _ordersRepo.Create(orders4);
            }
            if (ProductID5 == 5)
            {
                Inventory inventory5 = new Inventory
                {
                    LocationId = Locationid,
                    ProductId  = ProductID5,
                    Amount     = Amount5
                };

                Orders orders5 = new Orders
                {
                    OrderID   = orderid,
                    ProductID = ProductID5,
                    Amount    = Amount5
                };
                //finalize
                _inventoryRepo.Update(inventory5);
                _ordersRepo.Create(orders5);
            }



            return(RedirectToAction(nameof(Index)));
        }