コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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));
        }