예제 #1
0
            public Result ChangeStatus(OETLib.BusinessObjects.Model.UserOrders order)
            {
                Result webRes = new Result(false);

                try
                {
                    //set orderID from Order = userordid and update the staus of that specific order

                    Update_order = OETLib.BusinessObjects.Model.OrderList.GetOrderList().LastOrDefault(d => d.OrderID == order.OrderID);

                    // Update_order.UserID = order.UserID;
                    //Change processtatus
                    Update_order.ProcessStatusID = 2;
                    //try and save the updated order
                    var updateOrderSaveHelper = Update_order.TrySave(typeof(OETLib.BusinessObjects.Model.OrderList));
                    OETLib.BusinessObjects.Model.OrderList orderList = OETLib.BusinessObjects.Model.OrderList.GetOrderList();

                    // order.ProcessStatus = true;

                    //orderList.Add(Update_order);

                    //userOrderList.Save();

                    //Get the productId to be able to update the correct inventory
                    //Inventory_Product =OETLib.BusinessObjects.Model.InventoryList.GetInventoryList().LastOrDefault(d => d.ProductID == order.ProductID);
                    //var Inventory_record = new OETLib.BusinessObjects.Model.Inventory();
                    ////Set inventory elements
                    // Inventory_record.ProductID = order.ProductID;
                    // Inventory_record.InventoryQuantity = -order.ProductQuantity;
                    // Inventory_record.CurrentInventoryQuantity = Inventory_Product.CurrentInventoryQuantity - order.ProductQuantity;
                    // Inventory_record.InventoryItemCost = Inventory_Product.InventoryItemCost;
                    // Inventory_record.InventoryType = 2;



                    //Try and safe the new inventory record
                    //Inventory_record.TrySave(typeof(OETLib.BusinessObjects.Model.InventoryList));

                    // OETLib.BusinessObjects.Model.UserOrdersList userOrderList = OETLib.BusinessObjects.Model.UserOrdersList.GetUserOrdersList(false);
                    OETLib.BusinessObjects.Model.UserOrdersList userOrderList = OETLib.BusinessObjects.Model.UserOrdersList.GetUserOrdersList(1);
                    webRes.Success = true;
                    webRes.Data    = userOrderList;
                    // UserOrderList.Save();
                }
                catch (Exception e)
                {
                    webRes.ErrorText = e.Message;// "There was an error adding your order";
                }
                return(webRes);
            }
예제 #2
0
        public Result CancelOrder(OETLib.BusinessObjects.Model.myCart order)
        {
            Result webRes = new Result(false);

            try
            {
                // Delete Order from OrderDetail table
                OETLib.BusinessObjects.Model.OrderDetailList orderdetailList = OETLib.BusinessObjects.Model.OrderDetailList.GetOrderDetailList();
                var OrderDetailToDelete = OETLib.BusinessObjects.Model.OrderDetailList.GetOrderDetailList().LastOrDefault(d => d.OrderID == order.OrderID);
                orderdetailList.Remove(OrderDetailToDelete);
                orderdetailList.Save();

                // Delete canceled order from Order table
                OETLib.BusinessObjects.Model.OrderList orderlist = OETLib.BusinessObjects.Model.OrderList.GetOrderList();
                var OrderToDelete = OETLib.BusinessObjects.Model.OrderList.GetOrderList().LastOrDefault(d => d.OrderID == order.OrderID);
                //orderlist.Remove(OrderToDelete);
                OrderToDelete.ProcessStatusID = 3;
                OrderToDelete.TrySave(typeof(OETLib.BusinessObjects.Model.OrderList));
                //orderlist.Save();

                // Update the inventory stock levels. Stock needs to be added back to the inventory amounts
                // Get the latest inventory item to update in inventory
                var inventoryToUpdate = OETLib.BusinessObjects.Model.InventoryList.GetInventoryList().LastOrDefault(d => d.ProductID == order.ProductID);

                // new inventory record is created with the updated values
                var inventoryToCancel = new OETLib.BusinessObjects.Model.Inventory();
                inventoryToCancel.ProductID                = order.ProductID;
                inventoryToCancel.InventoryQuantity        = order.ProductQuantity;
                inventoryToCancel.CurrentInventoryQuantity = inventoryToUpdate.CurrentInventoryQuantity + order.ProductQuantity;
                inventoryToCancel.InventoryItemCost        = inventoryToUpdate.InventoryItemCost;
                inventoryToCancel.InventoryTypeID          = 4;
                inventoryToCancel.OrderID = order.OrderID;

                inventoryToCancel.TrySave(typeof(OETLib.BusinessObjects.Model.InventoryList));

                var userid = Singular.Settings.CurrentUserID;
                OETLib.BusinessObjects.Model.myCartList mycartlist = OETLib.BusinessObjects.Model.myCartList.GetmyCartList(userid);

                webRes.Data    = mycartlist;
                webRes.Success = true;
            }
            catch
            {
                webRes.ErrorText = "There was a problem cancelling order";
            }
            return(webRes);
        }
예제 #3
0
        protected override void Setup()
        {
            base.Setup();
            var userid = Singular.Settings.CurrentUserID;

            this.MyCartList      = OETLib.BusinessObjects.Model.myCartList.GetmyCartList(userid);
            this.ProductList     = OETLib.BusinessObjects.Model.ProductList.GetProductList();
            this.OrderList       = OETLib.BusinessObjects.Model.OrderList.GetOrderList();
            this.CategoryList    = OETLib.BusinessObjects.Model.CategoryList.GetCategoryList();
            this.OrderDetailList = OETLib.BusinessObjects.Model.OrderDetailList.GetOrderDetailList();
            this.InventoryList   = OETLib.BusinessObjects.Model.EditInventoryList.GetEditInventoryList();
            this.OnDemandList    = OETLib.BusinessObjects.Model.ProductList.GetOnDemandProducts(13);

            foreach (OETLib.BusinessObjects.Model.myCart item in MyCartList)
            {
                totalMonthPrice = totalMonthPrice + (item.ProductQuantity * item.ProductPrice);
            }
        }