Esempio n. 1
0
        public ActionResult Payment(string shipName, string mobile, string address, string email)
        {
            var order = new Order();

            order.CreateDate  = DateTime.Now;
            order.ShipName    = shipName;
            order.ShipMobile  = mobile;
            order.ShipAddress = address;
            order.ShipEmail   = email;

            try
            {
                var id        = new OrderDao().Insert(order);
                var cart      = (List <CartItem>)Session[CartSession];
                var detailDao = new Model.Dao.OrderDetailDao();


                foreach (var item in cart)
                {
                    var orderDetail = new OrderDetail();
                    var odd         = new OrderDetailDao();
                    orderDetail.ProductID = item.Product.ID;
                    orderDetail.OrderID   = id;
                    orderDetail.Price     = item.Product.Price;
                    orderDetail.Quantity  = item.Quantity;
                    //item.Product.Quantity -= item.Quantity;
                    odd.UpdatePDQuantity(item.Product, item.Quantity);
                    detailDao.Insert(orderDetail);
                }
            }
            catch (Exception)
            {
                return(Redirect("/gioi-thieu"));
            }
            return(Redirect("/hoan-thanh-don-hang"));
        }