Example #1
0
        public ActionResult ConfirmOrder(int cartID, int shipID, int billID, int cardID)
        {
            Customer         customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
            var              books    = db.Cart_Book.Where(x => x.CartID == cartID);
            List <Cart_Book> list     = new List <Cart_Book>();

            foreach (var item in books)
            {
                list.Add(item);
            }
            db.usp_AddInvoice(cartID, shipID, billID, cardID, customer.CustomerID);
            db.usp_CreateCart(customer.CustomerID);
            Invoice invoice = db.Invoices.Where(x => x.CartID == cartID).First();

            foreach (var item in list)
            {
                db.usp_AddBookToInvoice(item.BookID, invoice.InvoiceID, item.Amount, item.Price);
            }

            return(RedirectToAction("Index", "Invoice", null));
        }