Ejemplo n.º 1
0
        public ActionResult Purchase(Order model)
        {
            db.Orders.Add(model);

            var cart = ShoppingCart.Cart;
            foreach (var p in cart.Items)
            {
                var d = new OrderDetail
                {
                    Order = model,
                    ProductId = p.Id,
                    UnitPrice = p.UnitPrice,
                    Discount = p.Discount,
                    Quantity = p.Quantity
                };

                db.OrderDetails.Add(d);
            }
            db.SaveChanges();

            // Thanh toán trực tuyến
            //var api = new WebApiClient<AccountInfo>();
            //var data = new AccountInfo
            //{
            //    Id = Request["BankAccount"],
            //    Balance = cart.Total
            //};
            //api.Put("api/Bank/nn", data);
            return RedirectToAction("Detail", new { id = model.Id });
        }
Ejemplo n.º 2
0
        //
        // GET: /Order/
        public ActionResult Checkout()
        {
            var model = new Order();
            model.CustomerId = User.Identity.Name;
            model.OrderDate = DateTime.Now.Date;
            model.Amount = ShoppingCart.Cart.Total;

            return View(model);
        }