Пример #1
0
        public async Task Notify([FromQuery] string receiver, [FromQuery] string message, [FromQuery] int delayInSeconds, [FromQuery] int delayInMinutes)
        {
            if (string.IsNullOrWhiteSpace(receiver))
            {
                receiver = "ANY";
            }

            var scheduleAt = DateTimeOffset.Now
                             .AddSeconds(delayInSeconds)
                             .AddMinutes(delayInMinutes);

            await notificationScheduler.ScheduleAsync(message, scheduleAt);
        }
Пример #2
0
        public async Task <bool> ExecuteAsync(Guid neuronId, DateTimeOffset remindAt)
        {
            var neuron = await neuronRepository.GetByIdAsync(neuronId);

            var success = neuron.SetReminders(new[] { remindAt }, out var newReminders, out _);

            if (success)
            {
                await neuronRepository.AddRemindersAsync(newReminders);

                await scheduler.ScheduleAsync(neuron.Information, remindAt);
            }

            return(success);
        }