public ActionResult ProceedOrder(User user) { try { int Payamount = 0; string userId = HttpContext.Session.GetString("UserId"); List <Cart> carts = _cartRepo.GetByUser(); List <Models.Product> products = _productRepo.GetProduct(); // Set Pay Amount for (int i = 0; i < carts.Count; i++) { Payamount = Payamount + Convert.ToInt32(carts[i].Total); } //Order Models.Order order = new Models.Order(); order.Name = user.Name; order.Address = user.Address; order.State = user.State; order.City = user.City; order.PinCode = user.Pincode; order.Email = user.Email; order.Phone = user.Phone; order.CreateDate = DateTime.Now; order.Status = "InProgress"; order.UserId = Convert.ToInt32(userId); order.PayAmount = Payamount.ToString(); _orderRepo.InsertOrder(order); //Order Detail foreach (var item in carts) { Order_Detail order_Detail = new Order_Detail(); order_Detail.OrderId = order.Id; order_Detail.Qnt = item.Qnt; order_Detail.Price = Convert.ToInt32(item.Total); order_Detail.ProductId = item.ProductId; _orderRepo.InsertOrderDetail(order_Detail); _cartRepo.RemoveCartProcess(item); } return(RedirectToAction("PayPayment", new { OrderId = order.Id })); // bool result = _orderRepo.PlaceOrder(user); } catch (Exception) { throw; } }