Ejemplo n.º 1
0
        private async Task <DialogTurnResult> GetComputerRecommendations(WaterfallStepContext stepContext,
                                                                         CancellationToken cancellationToken)
        {
            await stepContext.Context.SendActivityAsync(
                BotStrings.We_taking_personal_info_retrieve_recommendations,
                cancellationToken : cancellationToken);

            var person = _accessors.GetPersonAsync(stepContext.Context, cancellationToken);

            if (_recommender.IsReadyToGiveRecommendation())
            {
                _recommender.GetNewComputerRecommendations(await person)
                .AsParallel()
                .ForAll(async r =>
                        await stepContext.Context.SendActivityAsync(r.RecommendMessage(),
                                                                    cancellationToken: cancellationToken));
            }
            else
            {
                await stepContext.Context.SendActivityAsync(BotStrings.No_Recommendation_engine,
                                                            cancellationToken : cancellationToken);
            }

            return(await stepContext.NextAsync(cancellationToken : cancellationToken));
        }
Ejemplo n.º 2
0
        private async Task <DialogTurnResult> SaveDetailsStep(WaterfallStepContext stepContext,
                                                              CancellationToken cancellationToken)
        {
            var person = await _personStateManager.GetPersonAsync(stepContext.Context, cancellationToken);

            var channelId = stepContext.Context.Activity.ChannelId;
            var userId    = stepContext.Context.Activity.From.Id;

            await stepContext.Context.SendActivityAsync(string.Format(BotStrings.Saving_info_of_user, userId, channelId), cancellationToken : cancellationToken);

            if (_dbContext.SavePerson(channelId, userId, person))
            {
                await stepContext.Context.SendActivityAsync(
                    BotStrings.Saving_your_data +
                    string.Format(BotStrings.data_gender, person.Gender.GetDescription()) +
                    string.Format(BotStrings.data_age, person.Age) +
                    string.Format(BotStrings.date_workArea, person.WorkArea),
                    cancellationToken : cancellationToken);
            }
            else
            {
                await stepContext.Context.SendActivityAsync(BotStrings.cant_save_your_data, cancellationToken : cancellationToken);
            }

            return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
        }