public ActionResult MoveOrderItemToOriginalOrder(int itemId) { var request = new MoveItemBackToOriginalOrderRequest { ItemId = itemId }; var response = this.itemsService.MoveOrderItemBackToOriginalOrder(request); var jsonNetResult = new JsonNetResult { Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented, Data = response.ConvertToPackageItemViewModel() }; return jsonNetResult; }
/// <summary> /// The move order item back to original order. /// </summary> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="MoveItemBackToOriginalOrderResponse"/>. /// </returns> public MoveItemBackToOriginalOrderResponse MoveOrderItemBackToOriginalOrder(MoveItemBackToOriginalOrderRequest request) { try { var item = this.itemsRepository.GetItemById(request.ItemId); if (item.PackageId != null) { var packageId = item.PackageId.Value; this.itemsRepository.DetachItemFromPackage(item.PackageId.Value, item.Id); var response = item.ConvertToMoveOrderItemToOriginalOrderResponse(); response.OrderId = item.OrderId; response.PackageId = packageId; response.MessageType = MessageType.Success; response.Message = string.Format(CommonResources.OrderItemMovedToOriginalOrder, item.OrderId); return response; } } catch (Exception ex) { this.Logger.Error("Error while moving order item back to original order", ex); return new MoveItemBackToOriginalOrderResponse { MessageType = MessageType.Error, Message = CommonResources.MoveOrderItemToOriginalOrderError }; } return null; }