Example #1
0
        public async Task DoWork(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                List <Session> sessions = new List <Session>();
                sessions = _pokerRepo.UpdateBalances();
                if (sessions == null)
                {
                    Console.WriteLine("A game is happening, balance changes will not be recorded.");
                }
                else
                {
                    var balances = _pokerRepo.GetUserBalances();
                    foreach (Session s in sessions)
                    {
                        var b    = balances.Where(b => b.UserID == s.UserID).FirstOrDefault();
                        var text = "Poker Session Total: " + s.Chips.ToString() + " Balance: " + b.Balance;
                        _slackClient.PostAPIMessage(
                            text: text,
                            channel: s.User.SlackID
                            );
                    }
                }


                await Task.Delay(900000, stoppingToken);  //run every 15 minutes
            }
        }
        public IActionResult Index(IFormCollection Form)
        {
            string userID = Form["user_id"];

            _slackClient.PostAPIMessage(
                text: "The server is up!",
                //username: userID,
                channel: userID
                );
            return(new EmptyResult());
        }