public async Task <IViewComponentResult> InvokeAsync(string resourceGroup, string automationAccount)
        {
            var runbooksNotLoaded = string.IsNullOrEmpty(HttpContext.Session.GetString("Runbooks"));

            ViewBag.RunbooksTitle = _configuration["Text:RunbooksTitle"];
            IList <RunbookSimple> runbooks;

            if (runbooksNotLoaded)
            {
                //Load runbooks from Azure
                runbooks = await _customAzureOperations.GetRunbooks(resourceGroup, automationAccount).ConfigureAwait(false);

                //Getting descriptions foreach runbook (these are not retrieved from ListRunbooks method) //TODO: only get runbook if LastModified is changed to save some miliseconds)
                await Task.Run(() => Parallel.ForEach(runbooks, runbook =>
                {
                    runbook.Description = _customAzureOperations.GetRunbook(resourceGroup, automationAccount, runbook.Name).GetAwaiter().GetResult().Description;
                }));

                var serializedRunbooks = JsonConvert.SerializeObject(runbooks);
                HttpContext.Session.SetString("Runbooks", serializedRunbooks);
            }
            else
            {
                //Runbooks already loaded within the user session (idletimeout set in appsettings) - just get them from session variable
                runbooks = JsonConvert.DeserializeObject <IList <RunbookSimple> >(HttpContext.Session.GetString("Runbooks"));
            }
            if (runbooks == null || runbooks.Count == 0)
            {
                ViewBag.NoRunbooks = _configuration["Text:NoRunbooks"];
            }
            return(View(runbooks));
        }
        public async Task <IActionResult> Submit(string signalRconnectionId, string runbookDisplayName, string runbookName, string runbookHybridWorkerGroup, Dictionary <string, string> inputs)
        {
            Dictionary <string, string> inputsSanitized = SanitizeInput(HttpContext, inputs);

            _messageSender.ConnectionId = signalRconnectionId;
            await _messageSender.SendMessage(_configuration["Text:OutputMessageJobStarted"]);

            //Initialize viewmodel
            AzureRunbookFormViewModel azureRunbookFormViewModel = new AzureRunbookFormViewModel
            {
                ResourceGroup     = _resourceGroup,
                AutomationAccount = _automationAccount,
                RunbookName       = runbookName,
                HybridWorkerGroup = runbookHybridWorkerGroup,
                Runbook           = new RunbookSimple {
                    Name = runbookName, DisplayName = runbookDisplayName
                },
                ResultsModel = new ResultsModel()
                {
                    JobInputs = inputsSanitized
                }
            };

            //AUDIT LOG - START
            if (Configuration.GetValue <bool>("EnableAuditLogging") == true)
            {
                AuditLog logEntry = new AuditLog
                {
                    RequestName  = runbookName,
                    RequestUser  = HttpContext.User.Identity.Name,
                    RequestInput = JsonConvert.SerializeObject(inputsSanitized, Formatting.None)
                };
                _automationPortalDbContext.Add(logEntry);

                await _automationPortalDbContext.SaveChangesAsync();
            }
            //AUDIT LOG - END

            if (CurrentPageType == PageType.Default)
            {
                //Check session cache for existing runbooks if this is null then retrieve runbooks from azure
                azureRunbookFormViewModel.Runbooks = string.IsNullOrEmpty(HttpContext.Session.GetString("Runbooks")) ?
                                                     await _customAzureOperations.GetRunbooks(_resourceGroup, _automationAccount).ConfigureAwait(false)
                    : JsonConvert.DeserializeObject <IList <RunbookSimple> >(HttpContext.Session.GetString("Runbooks"));

                return(View($"Result{CurrentPageType}", azureRunbookFormViewModel));
            }

            return(View($"Result{CurrentPageType}", azureRunbookFormViewModel));
        }