public ActionResult OrderProduct(int id) { CartRepo cr1 = new CartRepo(); CartModel cart2 = cr1.GetCart(id); int pId = (int)cart2.ProductID; int q = (int)cart2.Quantity; int c = (int)cart2.CustomerID; int tp = (int)cart2.TotalPrice; String pname = cart2.Product.ProductName; //orderModel = new OrderModel(15001, c, pId, pname, q, tp, null); orderModel = new OrderModel() { OrderID = 15001, CustomerID = c, ProductID = pId, ProductName = pname, Quantity = q, TotalPrice = tp, OrderDate = null }; Boolean b = op.AddOrder(orderModel); if (b == true) { cr1.DeleteProduct(cart2.CartID); pr = new ProductRepo(); pr.EditProductQuantity(pId, q); } return(RedirectToAction("ShowOrders")); }