private async Task SendScheduledRemindersAsync() { var reminders = await _storage.FindAsync(ReminderItemFilter.CreatedAtNow()); foreach (var reminder in reminders) { reminder.MarkReady(); await _storage.UpdateAsync(reminder); try { await _sender.SendAsync(new ReminderNotification( reminder.DateTime, reminder.Message, reminder.ChatId ) ); await OnReminderSentAsync(reminder); } catch (ReminderSenderException) { await OnReminderFailedAsync(reminder); } } }
public async Task <IActionResult> Find([FromQuery] FindReminderViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var items = await _storage.FindAsync(new ReminderItemFilter(model.DateTime, model.Status)); return(Ok(items)); }