Esempio n. 1
0
 public int CurrentNumberofHandsetsLeft()
 {
     return(handSets.BagCount());
 }
        private async Task UpdateUserAsync(IDialogContext context, int handSetsLeft, int handSetsB4)
        {
            StringBuilder sb = new StringBuilder("-->");
            string        acknowledgeMsg = decoder.LastOneWasNeed ? null : GetRightStringMsg(), aux;
            bool          removedSome = true;
            var           reply       = ((Activity)context.Activity).CreateReply("What else is important to refine it further?");

            if (CommonDialog.debugMessages)
            {
                await context.PostAsync($"DEBUG : Threshold = {decoder.Threshold}, desired intent = {desiredFeature}");

                await context.PostAsync("DEBUG : Ranking : \r\n");

                await context.PostAsync(sb.ToString() + "\r\n");
            }
            if (handSetsLeft == handSetsB4)
            {
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync("Unfortunately, that doesn't help in narrowing the list down");

                removedSome = false;
            }
            else if (handSetsLeft == 0)
            {
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync("I'm afraid that's a very high standard, I don't have any equipment that fulfills it.");

                removedSome  = false;
                handSetsLeft = handSetsB4;
            }
            if (handSetsLeft > BotConstants.MAX_CAROUSEL_CARDS)
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync($"DEBUG : There are {handSetsLeft} on bag");
                }
                if (removedSome && (acknowledgeMsg != null))
                {
                    await Miscellany.InsertDelayAsync(context);

                    await context.PostAsync(acknowledgeMsg);
                }
                aux = removedSome ? "We have now" : "We still have";
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync($"{aux} {handSetsLeft} models that might be suitable for your needs. I could help short list further if you tell me what else is important for you");

                sb = new StringBuilder("");
                reply.SuggestedActions = topButtons.GetTop4Buttons(sb);
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync(reply);
            }
            else
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("We have just 5 left or fewer");
                }
                if (acknowledgeMsg != null)
                {
                    await Miscellany.InsertDelayAsync(context);

                    await context.PostAsync(acknowledgeMsg);
                }
                if ((!decoder.LastOneWasNeed) && (desiredFeature == EIntents.Brand))
                {
                    context.ConversationData.SetValue(BotConstants.SELECTED_BRANDS_KEY, decoder.StrKeyWords);
                }
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync($"DEBUG : Number of phones on bag : {handSetsBag.BagCount()}");
                }
                context.Done(decoder);
            }
        }