public ActionResult Checkout(string receiver, string phone, string address) { User user = (User)Session["USER"]; if (user != null) { CartObj cart = (CartObj)Session["CART"]; if (cart != null) { DateTime date = DateTime.Now; OrderDAO daoOrder = new OrderDAO(); OrderDetailsDAO daoDetails = new OrderDetailsDAO(); Order order = new Order() { phone = phone, receiver = receiver, addressShip = address, username = user.username, orderDate= date}; daoOrder.Add(order); int currentID = daoOrder.GetCurrentOrderID(); foreach(var item in cart.cart) { OrderDetail details = new OrderDetail() { orderID = currentID, phoneID = item.Key.phoneID, price = item.Key.price, quantity = item.Value, discount = item.Key.discount }; daoDetails.Add(details); PhoneDAO daoPhone = new PhoneDAO(); daoPhone.UpdateQuantity(item.Value,item.Key.phoneID); } Session["CART"] = null; } } return RedirectToAction("Index", "Home", new { area = "" }); }