Example #1
0
        public IActionResult OnPost()
        {
            try
            {
                var runningJobs = _actionScheduler.GetRunningJobs <Core.Bot>();
                StartupMessage = _repository.List <Core.Data.StartupMessage>();
                var startUpMessage = StartupMessage.FirstOrDefault();

                if (runningJobs.Any())
                {
                    _bot.Stop("AlphaBot is offline."); // ToDo: add to database
                    _actionScheduler.StopRunningJobs <Core.Bot>();
                    IsRunning = false;
                }
                else
                {
                    _actionScheduler.Enqueue(() => _bot.Start(startUpMessage.Message));
                    IsRunning = true;
                }

                TimedMessages = _repository.List <Core.Data.TimedMessage>();
                ProjectText   = _repository.List <Core.Data.ProjectText>();
            }
            catch (Exception ex)
            {
                Log.Error($"Index.OnPost(): {ex.Message} - {ex.StackTrace}");
            }

            return(Page());
        }