public ActionResult CheckOut(FormCollection form) { var session = (Website_Panda.Models.Login.UserLogin)Session[Website_Panda.Models.Login.Common.USER_SESSION]; if (session == null) { return(View()); } else { CartSession cart = Session["CartSession"] as CartSession; Order _order = new Order(); _order.OrderDate = DateTime.Now; _order.IdCus = session.UserID; db.Order.Add(_order); foreach (var item in cart.Items) { OrderDetail _order_Detail = new OrderDetail(); _order_Detail.IDOrder = _order.IDOrder; _order_Detail.IDProduct = item._shopping_product.IDProduct; _order_Detail.Price = item._shopping_product.Price; _order_Detail.QuantitySale = item._shopping_quantity; db.OrderDetails.Add(_order_Detail); } db.SaveChanges(); cart.ClearCart(); return(RedirectToAction("Shopping_Success", "ShoppingCart")); //CartSession cart = Session["Cart"] as CartSession; //var result = from r in db.Customers // where r.IdCus == session.UserID // select r; //var cus2 = result.ToList().First(); //Order _order = new Order(); //_order.OrderDate = DateTime.Now; //_order.Email_Cus = cus2.Email_Cus; //_order.SDT_Cus = cus2.Phone_Cus; //_order.Password_cus = cus2.Password; //_order.Descriptions = cus2.Address_Cus; //_order.CodeCus = cus2.CodeCus; //_order.Deleted = false; //_order.Cancelled = false; //_order.Paid = false; //_order.Status = false; //db.Orders.Add(_order); } }