public ActionResult Reorder(int orderId) { // Gets the current shopping cart ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart(); // Adds products from the specified order to the current shopping cart // If the operation was successful, redirects to the shopping cart if (ShoppingCartInfoProvider.UpdateShoppingCartFromOrder(cart, orderId)) { // Displays the shopping cart return(RedirectToAction(nameof(CheckoutController.ShoppingCart), "Checkout")); } // If the reorder was unsuccessful, returns back to the list of customer's orders return(RedirectToAction(nameof(MyOrders))); }
/// <summary> /// Adds content of order to current shopping cart. /// </summary> private void AddToCart(int orderId) { if (!ShowOrderToShoppingCart) { return; } // Get order OrderInfo order = OrderInfoProvider.GetOrderInfo(orderId); if (order != null) { CustomerInfo customer = CustomerInfoProvider.GetCustomerInfo(order.OrderCustomerID); if (customer.CustomerUserID == CurrentUser.UserID) { // Get current shopping cart ShoppingCartInfo cart = ECommerceContext.CurrentShoppingCart; // Set new cart if (cart.ShoppingCartID == 0) { ShoppingCartInfoProvider.SetShoppingCartInfo(cart); } string cartUrl = ECommerceSettings.ShoppingCartURL(CurrentSite.SiteName); // Update shopping cart by items from order if (!ShoppingCartInfoProvider.UpdateShoppingCartFromOrder(cart, orderId)) { cartUrl = URLHelper.AddParameterToUrl(cartUrl, "notallreordered", "1"); } // Update shopping cart items in database foreach (ShoppingCartItemInfo item in cart.CartItems) { ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(item); } // Redirect to shopping cart page URLHelper.ResponseRedirect(cartUrl); } } }