Exemple #1
0
        /// <summary>
        /// Method to request more information details card from new hire.
        /// </summary>
        /// <param name="turnContext">Provides context for a turn of a bot.</param>
        /// <param name="valuesfromCard">Values from card.</param>
        /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
        /// <returns>Request more information notification card.</returns>
        public async Task RequestMoreInfoActionAsync(ITurnContext <IMessageActivity> turnContext, AdaptiveSubmitActionData valuesfromCard, CancellationToken cancellationToken)
        {
            turnContext    = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
            valuesfromCard = valuesfromCard ?? throw new ArgumentNullException(nameof(valuesfromCard));

            if (string.IsNullOrEmpty(valuesfromCard.Comments))
            {
                await turnContext.SendActivityAsync(this.localizer.GetString("TellMeMoreInputValidationText"));

                return;
            }

            var introduction = await this.introductionStorageProvider.GetIntroductionDetailAsync(
                valuesfromCard.IntroductionEntity.NewHireAadObjectId,
                valuesfromCard.IntroductionEntity.ManagerAadObjectId);

            if (introduction.ApprovalStatus == (int)IntroductionStatus.Approved)
            {
                await turnContext.SendActivityAsync(this.localizer.GetString("ManagerApprovalValidationText"));
            }
            else
            {
                valuesfromCard.IntroductionEntity.Comments       = valuesfromCard.Comments;
                valuesfromCard.IntroductionEntity.ApprovalStatus = (int)IntroductionStatus.TellMeMore;
                await this.introductionStorageProvider.StoreOrUpdateIntroductionDetailAsync(valuesfromCard.IntroductionEntity);

                var newHireNotification = MessageFactory.Attachment(TellMeMoreCard.GetCard(this.botOptions.Value.AppBaseUri, this.localizer, valuesfromCard.IntroductionEntity));
                newHireNotification.Conversation = new ConversationAccount {
                    Id = valuesfromCard.IntroductionEntity.NewHireConversationId
                };
                await turnContext.Adapter.SendActivitiesAsync(turnContext, new Activity[] { (Activity)newHireNotification }, cancellationToken);

                await turnContext.SendActivityAsync(this.localizer.GetString("RequestMoreInfoNotificationText"));
            }
        }
 /// <summary>
 /// Gets introduction validation card to show in task module.
 /// </summary>
 /// <param name="introductionEntity">New hire introduction details.</param>
 /// <returns>Envelope for Task Module Response.</returns>
 public TaskModuleResponse GetIntroductionValidationCard(IntroductionEntity introductionEntity)
 {
     return(new TaskModuleResponse
     {
         Task = new TaskModuleContinueResponse
         {
             Value = new TaskModuleTaskInfo()
             {
                 Card = TellMeMoreCard.GetValidationMessageCard(introductionEntity, this.localizer),
                 Height = ValidationMessageTaskModuleHeight,
                 Width = ValidationMessageTaskModuleWidth,
                 Title = this.localizer.GetString("AppTitle"),
             },
         },
     });
 }