public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default)
        {
            var text      = dc.Context.GetTextWithoutCommand(BotCommands.NewTeamDialog);
            var positions = await _positionService.Search(text, 15, cancellationToken);

            if (positions.Count == 1)
            {
                var connectionName = _appSettings.OAuthConnectionName;
                var token          = await((IUserTokenProvider)dc.Context.Adapter)
                                     .GetUserTokenAsync(dc.Context, connectionName, null, cancellationToken);
                var(team, displayName) = await _graphApiService.CreateNewTeamForPosition(positions[0], token.Token, cancellationToken);

                await dc.Context.SendActivityAsync($"[Team {displayName}]({team.WebUrl}) has been created.", cancellationToken : cancellationToken);
            }
            else
            {
                var positionsTemplate = new PositionTemplateModel
                {
                    Items         = positions,
                    NoItemsLabel  = "You don't have such open positions.",
                    BotCommand    = BotCommands.NewTeamDialog,
                    ListCardTitle = "I found following positions:",
                };

                await _positionsTemplate.ReplyWith(dc.Context, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate);
            }

            return(await dc.EndDialogAsync(cancellationToken : cancellationToken));
        }
예제 #2
0
        public override async Task <DialogTurnResult> BeginDialogAsync(
            DialogContext dc,
            object options = null,
            CancellationToken cancellationToken = default)
        {
            var text      = dc.Context.GetTextWithoutCommand(BotCommands.PositionsDetailsDialogCommand);
            var positions = new List <Position>();

            if (!string.IsNullOrEmpty(text))
            {
                var position = int.TryParse(text, out var positionId)
                    ? await _positionService.GetById(positionId)
                    : await _positionService.GetByExternalId(text, cancellationToken);

                if (position != null)
                {
                    positions.Add(position);
                }
            }

            var positionsTemplate = new PositionTemplateModel
            {
                Items        = positions,
                NoItemsLabel = "I couldn't find this position."
            };

            await _positionsTemplate.ReplyWith(dc.Context, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate);

            return(await dc.EndDialogAsync(cancellationToken : cancellationToken));
        }
        public override async Task <DialogTurnResult> BeginDialogAsync(
            DialogContext dc,
            object options = null,
            CancellationToken cancellationToken = default)
        {
            var text      = dc.Context.GetTextWithoutCommand(BotCommands.TopCandidatesDialogCommand);
            var positions = await _positionService.Search(text, 15, cancellationToken);

            if (positions.Count == 1)
            {
                var candidates   = positions[0].Candidates;
                var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken);

                CandidateTemplateModel templateModel = new CandidateTemplateModel
                {
                    ListCardTitle = "Top candidates who have recently applied to your position:",
                    BotCommand    = BotCommands.CandidateDetailsDialogCommand,
                    Items         = candidates,
                    Interviewers  = interviewers,
                    AppSettings   = _appSettings,
                    NoItemsLabel  = $"There are no candidates for position ID: {positions[0].PositionExternalId}"
                };

                await _candidatesTemplate.ReplyWith(dc.Context, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel);
            }
            else
            {
                PositionTemplateModel positionsTemplate = new PositionTemplateModel
                {
                    ListCardTitle = "I found several positions. Please specify:",
                    Items         = positions,
                    BotCommand    = BotCommands.TopCandidatesDialogCommand,
                    NoItemsLabel  = "You don't have open position with such ID."
                };

                await _positionsTemplate.ReplyWith(dc.Context, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate);
            }

            return(await dc.EndDialogAsync(cancellationToken : cancellationToken));
        }
예제 #4
0
        public override async Task <DialogTurnResult> BeginDialogAsync(
            DialogContext dc,
            object options = null,
            CancellationToken cancellationToken = default)
        {
            var openPositions = await _positionService.GetOpenPositions(dc.Context.Activity.From.Name, cancellationToken);

            var positionsTemplate = new PositionTemplateModel
            {
                ListCardTitle = $"You have {openPositions.Count} active postings right now:",
                Items         = openPositions,
                BotCommand    = BotCommands.PositionsDetailsDialogCommand,
                NoItemsLabel  = "You have no open positions",
                ButtonActions = new Dictionary <string, string>
                {
                    { "Add new job posting", BotCommands.NewJobPostingDialog }
                }
            };

            await _positionsTemplate.ReplyWith(dc.Context, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate);

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