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); } }
public virtual IActionResult Edit(ConsignmentOrderModel model, bool continueEditing) { if (!permissionService.Authorize(StandardPermissionProvider.ManageConsignmentOrders)) { return(AccessDeniedView()); } var entity = consignmentOrderService.Get(model.Id); if (null == entity || entity.Deleted) { return(RedirectToAction("List")); } if (ModelState.IsValid) { entity = model.ToEntity(entity); consignmentOrderService.Update(entity); customerActivityService.InsertActivity("EditConsignmentOrder", string.Format(localizationService.GetResource("ActivityLog.EditConsignmentOrder"), entity.Id), entity); SuccessNotification(localizationService.GetResource("Admin.Logistics.ConsignmentOrder.Updated")); if (!continueEditing) { return(RedirectToAction("List")); } SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = entity.Id })); } model = consignmentOrderFactory.PrepareModel(model, entity, true); return(View(model)); }