public async Task <IActionResult> PostReminder([FromBody] Reminder reminder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newReminder = await _reminderRepository.AddAsync(reminder);

            var jobId = BackgroundJob.Schedule(() => SendEmail(), newReminder.RemindDate);

            await _reminderJobRepository.AddAsync(new ReminderJob { ReminderId = newReminder.Id, JobId = jobId });

            return(Ok(newReminder));
        }
Ejemplo n.º 2
0
        public async Task <ReminderRegistration> RegisterAsync(string userId, ReminderRequest request)
        {
            var registration = new ReminderRegistration()
            {
                Expires = DateTime.Now.AddMinutes(ExpirationMinutes),
                Id      = Guid.NewGuid().ToString()
            };
            await reminderRepository.AddAsync(userId, request, registration);

            await calendarService.InstallNotifications(userId);

            await MaintainReminderAsync(registration.Id);

            return(registration);
        }