public async Task <IMessageActivity> LeaveInternalCommentAsync( ITurnContext turnContext, CancellationToken cancellationToken) { var commandData = JsonConvert.DeserializeObject <LeaveCommentCommand>(turnContext.Activity.Value?.ToString()); if (commandData is null) { return(null); } await _candidateService.AddComment(commandData, turnContext.Activity.From.Name, cancellationToken); var candidate = await _candidateService.GetById(commandData.CandidateId, cancellationToken); var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); var templateModel = new CandidateTemplateModel { Items = new List <Candidate> { candidate }, Interviewers = interviewers, AppSettings = _appSettings, NoItemsLabel = "You don't have such candidate." }; var messageActivity = await _candidatesTemplate.RenderTemplate(turnContext, null, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel); return(messageActivity); }
private async Task <AdaptiveCard> LeaveInternalComment(Activity activity, CancellationToken cancellationToken) { var commandData = JsonConvert.DeserializeObject <LeaveCommentCommand>(activity.Value?.ToString()); if (commandData is null) { return(null); } await _candidateService.AddComment(commandData, activity.From.Name, cancellationToken); var candidate = await _candidateService.GetById(commandData.CandidateId, cancellationToken); return(_mapper.Map <AdaptiveCard>(candidate)); }
public async Task <HttpResponseMessage> HandleButtonClickEvent(HttpRequestMessage request, string commandId, Activity activity, CancellationToken cancellationToken) { switch (commandId) { case AppCommands.LeaveInternalComment: var leaveCommentRequest = JsonConvert.DeserializeObject <LeaveCommentCommand>(activity?.Value?.ToString()); await _candidateService.AddComment(leaveCommentRequest, activity?.From.Name, cancellationToken); break; case AppCommands.ScheduleInterview: var scheduleInterviewRequest = JsonConvert.DeserializeObject <ScheduleInterviewCommand>(activity?.Value?.ToString()); await _interviewService.ScheduleInterview(scheduleInterviewRequest, cancellationToken); break; } return(request.CreateResponse(HttpStatusCode.OK)); }
public async Task <InvokeResponse> HandleMessagingExtensionOnCardButtonClickedAsync(ITurnContext <IInvokeActivity> turnContext, CancellationToken cancellationToken) { var data = turnContext.TurnState.Get <ITeamsContext>().GetMessagingExtensionQueryData(); switch (data.CommandId) { case AppCommands.LeaveInternalComment: var leaveCommentRequest = JsonConvert.DeserializeObject <LeaveCommentCommand>(turnContext.Activity?.Value?.ToString()); await _candidateService.AddComment(leaveCommentRequest, turnContext.Activity?.From.Name, cancellationToken); break; case AppCommands.ScheduleInterview: var scheduleInterviewRequest = JsonConvert.DeserializeObject <ScheduleInterviewCommand>(turnContext.Activity?.Value?.ToString()); await _interviewService.ScheduleInterview(scheduleInterviewRequest, cancellationToken); break; } return(new InvokeResponse { Status = (int)HttpStatusCode.OK }); }