public IHttpActionResult SendSlackTeamNotifications()
        {
            var teamNotificationBusiness = new TeamNotificationBusiness();

            // async run business, return OK immediately
            Task.Run(() =>
            {
                teamNotificationBusiness.SendSlackTeamNotifications();
            });

            return(Ok());
        }
        private void SaveArbitrageNotification(Currency currency, decimal percentage)
        {
            var key = "arb:" + (int)currency + ":" + percentage.ToMoneyMarketMoneyFormat();

            var teamNotification = new Dto.TeamNotification
            {
                TeamId           = Team.Id,
                NotificationType = NotificationType.Arbitrage,
                Key            = key,
                LastExecutedAt = DateTime.UtcNow,
                TimeInterval   = 0
            };

            var teamNotificationBusiness = new TeamNotificationBusiness();

            // add or update notification
            teamNotificationBusiness.Add(teamNotification);
        }
        private void SavePriceTrackerNotification(Currency currency, Provider provider, decimal limitAmount, MainCurrency mainCurrency)
        {
            var cryptoCurrencies = GetCryptoCurrencies(currency);

            var limitAmountUsdValue = GetCurrentUsdValueByMainCurrency(limitAmount, mainCurrency);

            Dto.CryptoCurrency cryptoCurrency;

            if (provider == Provider.Unknown)
            {
                cryptoCurrency = cryptoCurrencies.First(p => p.Provider == Provider.CoinMarketCap);
            }
            else
            {
                cryptoCurrency = cryptoCurrencies.First(p => p.Provider == provider);
            }

            var alarmType = cryptoCurrency.UsdValue > limitAmountUsdValue ? AlarmType.Purchase : AlarmType.Sell;

            var key = (int)provider + ":" + (int)currency + ":" + limitAmount.ToMoneyMarketCryptoCurrencyFormat() + ":" + (int)mainCurrency + ":" + (int)alarmType;

            var teamNotification = new Dto.TeamNotification
            {
                TeamId           = Team.Id,
                NotificationType = NotificationType.PriceTracker,
                Key            = key,
                LastExecutedAt = DateTime.UtcNow,
                TimeInterval   = 0 // 0 for alarms
            };

            var teamNotificationBusiness = new TeamNotificationBusiness();

            if (limitAmount == 0)
            {
                //user wants to snooze notification
                teamNotificationBusiness.Delete(teamNotification);
                return;
            }

            // add or update notification
            teamNotificationBusiness.Add(teamNotification);
        }
        private void SaveAssetReminderTrackerNotification(Currency currency, int timeInterval)
        {
            var teamNotification = new Dto.TeamNotification
            {
                TeamId           = Team.Id,
                NotificationType = NotificationType.AssetReminder,
                Key            = ((int)currency).ToString(),
                LastExecutedAt = DateTime.UtcNow,
                TimeInterval   = timeInterval
            };

            var teamNotificationBusiness = new TeamNotificationBusiness();

            if (timeInterval == 0)
            {
                //user wants to snooze notification
                teamNotificationBusiness.Delete(teamNotification);
                return;
            }

            // add or update notification
            teamNotificationBusiness.Add(teamNotification);
        }