Example #1
0
        public ActionResult Checkout()
        {
            string  username  = Session["username"].ToString();
            Account a         = new AccountServ.AccountServiceClient().getAccountByUsername(username);
            int     accountID = a.ID;

            Order o       = new ProductOrderServ.ProductOrderClient().getUserProductOrder(accountID, "Ordered");
            int   orderID = o.ID;

            Order order = new Order();

            order.ID                 = o.ID;
            order.DateOfPurchase     = o.DateOfPurchase;
            order.WarrantyExpiryDate = o.WarrantyExpiryDate;
            order.Status             = "Shipped";
            order.AccountID          = o.AccountID;

            foreach (ProductOrder p in o.ProductOrder)
            {
                ProductServ.ProductServiceClient productClient = new ProductServ.ProductServiceClient();
                Product product = productClient.GetProductByID(p.ProductID);
                product.StockAmount = product.StockAmount - p.Quantity;
                productClient.UpdateProductStock(product.StockAmount.Value, product.ID);
            }
            //Product p = new ProductServ.ProductServiceClient().GetProductByID(o.ProductOrder.
            new ProductOrderServ.ProductOrderClient().UpdateOrder(order);
            return(RedirectToAction("ProductList", "Product"));
        }