Exemplo n.º 1
0
 public int Insert(Order order)
 {
     using(ThucLop db = new ThucLop())
     {
         db.Orders.Add(order);
         db.SaveChanges();
         return order.ID;
     }
 }
Exemplo n.º 2
0
        public ActionResult Payment(string shipName, string Address, string Phone, string email)
        {
            var order = new Order();
            order.CreatedDate = DateTime.Now;
            order.ShipName = shipName;
            order.ShipAddress = Address;
            order.ShipMobile = Phone;
            order.ShipEmail = email;
            try
            {
                var id = new OrderDAO().Insert(order);
                var cart = (List<CartItem>)Session[CartSession];
                var detailDao = new OrderDetailDAO();
                foreach (var item in cart)
                {
                    var orderDetail = new OderDetail();
                    orderDetail.ProductID = item.Product.ID;
                    orderDetail.OrderID = id;
                    orderDetail.Price = item.Product.Price;
                    orderDetail.Quantity = item.Quantity;
                    detailDao.Insert(orderDetail);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return RedirectToAction("Finish");
        }