コード例 #1
0
        public List <OrderError> DeleteOrders(int[] ordersId, string usernameOrEmail, string userPassword)
        {
            CheckAccess(usernameOrEmail, userPassword);

            if (!_permissionSettings.Authorize(StandardPermissionProvider.ManageOrders))
            {
                throw new ApplicationException("Not allowed to manage orders");
            }

            var errors = new List <OrderError>();

            foreach (var order in GetOrderCollection(ordersId))
            {
                try
                {
                    _orderProcessingService.DeleteOrder(order);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.Message);
                }
            }

            return(errors);
        }
コード例 #2
0
        public virtual IActionResult CancelOrder(IFormCollection form)
        {
            string id = Request.Query["id"];

            if (!string.IsNullOrEmpty(id))
            {
                //return RedirectToRoute("OrderDetails", new { orderId = id });
                if (int.TryParse(id, out int orderId))
                {
                    // Get order that was canceled
                    Order order = _orderService.GetOrderById(orderId);
                    if (order != null)
                    {
                        if (order.OrderStatus == OrderStatus.Pending && _orderProcessingService.CanCancelOrder(order))
                        {
                            // Reorder items - place order items in shopping cart.
                            _orderProcessingService.ReOrder(order);
                            // Delete the order to avoid customer confusion
                            _orderProcessingService.DeleteOrder(order);
                        }

                        // Redirect customer to shopping cart
                        return(RedirectToRoute("ShoppingCart"));
                    }
                }
            }

            return(RedirectToAction("Index", "Home", new { area = "" }));
        }
コード例 #3
0
        public 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"));
            }

            _orderProcessingService.DeleteOrder(orderToDelete);

            //activity log
            CustomerActivityService.InsertActivity("DeleteOrder", LocalizationService.GetResource("ActivityLog.DeleteOrder"), orderToDelete);

            return(new RawJsonActionResult("{}"));
        }
コード例 #4
0
 /// <summary>
 /// Deletes an order
 /// </summary>
 /// <param name="order">The order</param>
 public void DeleteOrder(Order order)
 {
     _orderProcessingService.DeleteOrder(order);
 }