Exemple #1
0
        /// <summary>
        /// This function contains the logic to run the feature.
        /// </summary>
        public async Task CheckStock(string symbol, string email)
        {
            // 1) IO - Get necessary data
            var stock = await _stockApi.GetStock(symbol);

            var thresholds = await _database.GetThresholds(symbol, email);

            if (stock != null && thresholds != null)
            {
                // 2) Process business rules to create an alert (or not).
                var message = MaybeCreateMessage(stock, thresholds);

                // 3) IO - Send the message (if one exists)
                if (message != null)
                {
                    await _messageSvc.SendMessage(message);
                }
                else
                {
                    Console.WriteLine("No message was sent.");
                }
            }
            else
            {
                Console.WriteLine("Requires stock and threshold.");
            }
        }