private async Task <DialogTurnResult> StopProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var msg = string.Empty; var result = stepContext.Result.ToString(); var processDetails = (ProcessDetails)stepContext.Options; processDetails.Action = string.Empty; var rpaService = new RPAService(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Stop" && promptOption.Id != "mainMenu") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } if (result.ToLower() == "1" || result.ToLower() == "2" || result.ToLower() == "3") { var response = new APIResponse(); if (result.ToLower() == "3") { response = rpaService.CancelQueuedProcess(processDetails.ProcessSelected); } else { response = rpaService.StopProcess(processDetails.ProcessSelected.Sys_id, Convert.ToInt32(result)); } if (response.IsSuccess) { if (!string.IsNullOrEmpty(response.Content)) { msg = response.Content; } else { if (result.ToLower() == "3") { msg = "Process " + processDetails.ProcessSelected.Name + " has been successfully deleted from the queue."; } else { msg = "Request to Stop Process " + processDetails.ProcessSelected.Name + " Submitted. Please allow a few minutes for the status to refresh."; } } } else { if (!string.IsNullOrEmpty(response.Error)) { msg = response.Error; } else { msg = response.Message; } } await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(msg) }, cancellationToken); return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); }