private async Task <DialogTurnResult> donePrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var sPackToHandlingUnit = (string)step.Result;

            ((PickBatchPickingPost)step.Values[DialogKey]).sPackToHandlingUnit = sPackToHandlingUnit;

            //Custom Code Start | Added Code Block
            //If the handling unit does not exist we create it

            long ixHandlingUnit = 0;

            if (!_movequeuesService.HandlingUnitsDb().Where(x => x.sHandlingUnit.Trim() == sPackToHandlingUnit.Trim()).Any())
            {
                HandlingUnitsPost handlingUnitsPost = new HandlingUnitsPost();
                handlingUnitsPost.sHandlingUnit      = sPackToHandlingUnit.Trim();
                handlingUnitsPost.ixHandlingUnitType = _commonLookUps.getHandlingUnitTypes().Where(x => x.sHandlingUnitType == "Carton").Select(x => x.ixHandlingUnitType).FirstOrDefault();
                handlingUnitsPost.UserName           = step.Context.Activity.Conversation.Id;
                ixHandlingUnit = _handlingunitsService.Create(handlingUnitsPost).Result;
            }
            else
            {
                ixHandlingUnit = _movequeuesService.HandlingUnitsDb().Where(x => x.sHandlingUnit == sPackToHandlingUnit.Trim()).Select(x => x.ixHandlingUnit).FirstOrDefault();
            }
            ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit = ixHandlingUnit;

            var inventoryUnitPicked = _inventoryunitsService.GetPost((long)step.Values[PickedInventoryUnitKey]);

            inventoryUnitPicked.ixHandlingUnit = ixHandlingUnit;
            inventoryUnitPicked.UserName       = step.Context.Activity.Conversation.Id;
            await _inventoryunitsService.Edit(inventoryUnitPicked, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());

            //We create the packing record
            var orderLinesToPack = ((List <Tuple <Int64, double> >)step.Values[LineQtysPickedKey]).GroupBy(x => x.Item1).Select(x => new { ixOutboundOrderLine = x.Key, Total = x.Sum(s => s.Item2) }).ToList();

            orderLinesToPack.ForEach(x =>
            {
                //We check if there is an existing pack record we can use
                if (
                    _outboundorderlinepackingService.IndexDb().Where(p =>
                                                                     p.ixHandlingUnit == ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit &&
                                                                     p.ixOutboundOrderLine == x.ixOutboundOrderLine
                                                                     ).Any()
                    )
                {
                    var outboundorderlinepack = _outboundorderlinepackingService.GetPost(_outboundorderlinepackingService.IndexDb().Where(p =>
                                                                                                                                          p.ixHandlingUnit == ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit &&
                                                                                                                                          p.ixOutboundOrderLine == x.ixOutboundOrderLine
                                                                                                                                          ).Select(p => p.ixOutboundOrderLinePack).FirstOrDefault()
                                                                                         );
                    outboundorderlinepack.nBaseUnitQuantityPacked += x.Total;
                    outboundorderlinepack.UserName = step.Context.Activity.Conversation.Id;
                    _outboundorderlinepackingService.Edit(outboundorderlinepack);
                }
                else
                {
                    var outboundorderlinepack = new OutboundOrderLinePackingPost();
                    outboundorderlinepack.ixOutboundOrderLine     = x.ixOutboundOrderLine;
                    outboundorderlinepack.ixHandlingUnit          = ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit;
                    outboundorderlinepack.nBaseUnitQuantityPacked = x.Total;
                    outboundorderlinepack.ixStatus = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
                    outboundorderlinepack.UserName = step.Context.Activity.Conversation.Id;
                    _outboundorderlinepackingService.Create(outboundorderlinepack);
                }
            }
                                     );

            //Custom Code End

            return(await step.EndDialogAsync(
                       (PickBatchPickingPost)step.Values[DialogKey],
                       cancellationToken));
        }