private static async void HandleNotificationWhenRateWillLessThan(RateNotificationTask task, CurrencyDto currencyInfo, TraceWriter log) { if (currencyInfo.price_usd < task.Value) { task.IsDone = true; var taskRepository = new RateNotificationTaskRepository(); await taskRepository.Replace(task); var message = $"Warning. {currencyInfo.name}({currencyInfo.symbol}) is less than {task.Value} USD. ({currencyInfo.price_usd})"; await SendMessageToChannel(message, task.ConnectionParameters, log); } }
private static async void HandleNotificationWhenRateWillDecreaseBy(RateNotificationTask task, CurrencyDto currencyInfo, TraceWriter log) { var diff = task.CurrentPrice - currencyInfo.price_usd; if (diff >= task.Value) { task.IsDone = true; var taskRepository = new RateNotificationTaskRepository(); await taskRepository.Replace(task); var message = $"Warning. The {currencyInfo.name}({currencyInfo.symbol}) rate fell by {task.Value} USD. ({currencyInfo.price_usd})"; await SendMessageToChannel(message, task.ConnectionParameters, log); } }