Esempio n. 1
0
        public async System.Threading.Tasks.Task <IActionResult> OrderRefreshAsync(int orderId = 0)
        {
            if (orderId > 0)
            {
                Order lastOrder = (await _orderService.GetOrderByIdAsync(orderId));

                if (lastOrder != null)
                {
                    if (lastOrder.PaymentMethodSystemName.ToLower().Equals("payments.param"))
                    {
                        if (lastOrder.PaymentStatus == PaymentStatus.Pending)
                        {
                            if (_orderProcessingService.CanCancelOrder(lastOrder))
                            {
                                await _orderProcessingService.DeleteOrderAsync(lastOrder);

                                await _orderProcessingService.ReOrderAsync(lastOrder);

                                return(RedirectToRoute("Checkout"));
                            }
                        }
                    }
                }

                return(RedirectToRoute("OrderDetails", new { orderId = orderId }));
            }

            return(RedirectToRoute("Cart"));
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteOrder(int id)
        {
            if (id <= 0)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var orderToDelete = _orderApiService.GetOrderById(id);

            if (orderToDelete == null)
            {
                return(Error(HttpStatusCode.NotFound, "order", "not found"));
            }

            await _orderProcessingService.DeleteOrderAsync(orderToDelete);

            //activity log
            await CustomerActivityService.InsertActivityAsync("DeleteOrder", await LocalizationService.GetResourceAsync("ActivityLog.DeleteOrder"), orderToDelete);

            return(new RawJsonActionResult("{}"));
        }