Esempio n. 1
0
        public virtual void AddOrderToTrip(int tripId, int[] orderIds)
        {
            if (null == orderIds || !orderIds.Any())
            {
                throw new NopException(localizationService.GetResource("Admin.Logistics.Trip.Orders.AddNew.OrderIds.Required"));
            }

            var trip = tripService.Get(tripId);

            if (null == trip)
            {
                throw new NopException(localizationService.GetResource("Admin.Logistics.Trip.TripNotExists"));
            }

            foreach (var orderId in orderIds)
            {
                var order = consignmentOrderService.Get(orderId);
                if (null == order)
                {
                    throw new NopException(localizationService.GetResource("Admin.Logistics.Trip.ConsignmentOrderNotExists"));
                }

                if (trip.Orders.Any(x => x.Id == order.Id))
                {
                    throw new NopException(localizationService.GetResource("Admin.Logistics.Trip.TripExistsConsignmentOrder"));
                }

                order.TripId = tripId;
                consignmentOrderService.Update(order);
            }
        }
Esempio n. 2
0
        public virtual IActionResult Edit(int id)
        {
            if (!permissionService.Authorize(StandardPermissionProvider.ManageConsignmentOrders))
            {
                return(AccessDeniedView());
            }

            var entity = consignmentOrderService.Get(id);

            if (null == entity || entity.Deleted)
            {
                return(RedirectToAction("List"));
            }

            var model = consignmentOrderFactory.PrepareModel(null, entity);

            return(View(model));
        }