public ActionResult ConfirmCheckout() { MyCart myCart = Session["cart"] as MyCart; UserDetail currentUser = db.UserDetails.Find(WebSecurity.CurrentUserId); Order newOrder = new Order() { Email = currentUser.Email, Phone = currentUser.Phone, ShipAddress = currentUser.Address, UserDetailId = currentUser.Id }; db.Orders.Add(newOrder); foreach (var item in myCart.CartItems) { OrderDetail od = new OrderDetail() { Count = item.Count, AlbumId = item.Id, Discount = 0, Order = newOrder, Price = item.Price }; db.OrderDetails.Add(od); } db.SaveChanges(); myCart.ClearCart(); return(RedirectToAction("Index", "Home")); }