Ejemplo n.º 1
0
        private void OnCreatedTimerTick(object _)
        {
            var filter = new ReminderItemFilter(DateTimeOffset.UtcNow, ReminderItemStatus.Created);
            var items  = _storage.FindBy(filter);

            foreach (var item in items)
            {
                _storage.Update(item.ReadyToSend());
            }
        }
Ejemplo n.º 2
0
        private void OnCreatedItemTimerTick(object _)
        {
            var filter = ReminderItemFilter
                         .ByStatus(ReminderItemStatus.Created)
                         .At(DateTimeOffset.Now);
            var items = _storage.FindBy(filter);

            foreach (var item in items)
            {
                _storage.Update(item.ReadyToSend());
            }
        }
Ejemplo n.º 3
0
        private void OnCreatedItemTimerTick(object state)
        {
            var filter = new ReminderItemFilter()
                         .At(DateTimeOffset.Now)
                         .Created();


            var items = _storage.FindBy(filter);

            foreach (var item in items)
            {
                _storage.Update(item.ReadyToSend());
            }
        }
Ejemplo n.º 4
0
        private void OnTimerTick(object state)
        {
            _logger.LogDebug("Ticked timer");

            var datetime  = DateTimeOffset.UtcNow;
            var reminders = _storage.FindBy(ReminderItemFilter.CreatedAt(datetime));

            foreach (var reminder in reminders)
            {
                _logger.LogInformation($"Mark reminder {reminder.Id:N} as ready");
                reminder.MarkReady();

                try
                {
                    _logger.LogInformation($"Sending reminder {reminder.Id:N}");
                    _sender.Send(
                        new ReminderNotification(
                            reminder.ContactId,
                            reminder.Message,
                            reminder.DateTime
                            )
                        );
                    OnReminderSent(reminder);
                }
                catch (ReminderSenderException exception)
                {
                    _logger.LogError(exception, "Exception occured while sending notification");
                    OnReminderFailed(reminder);
                }
            }
        }
Ejemplo n.º 5
0
        public IActionResult GetList([FromQuery()] ReminderFilterViewModel model)
        {
            var filter = new ReminderItemFilter(model?.DateTime, model?.Status);
            var items  = _storage.FindBy(filter);

            return(Ok(items));
        }
Ejemplo n.º 6
0
        public IActionResult GetAll([FromQuery] ReminderItemFilterViewModel filter)
        {
            var result = _storage.FindBy(
                new ReminderItemFilter(
                    page: new PageInfo((uint)filter.PageNumber, (uint)filter.PageSize),
                    datetimeUtc: DateTimeOffset.FromUnixTimeMilliseconds(filter.DateTimeUtc),
                    status: filter.Status
                    )
                );
            var model = new PagedViewModel(result);

            return(Ok(model));
        }
Ejemplo n.º 7
0
        public IActionResult GetAll([FromQuery] ReminderItemFilterViewModel filter)
        {
            if (filter == default)
            {
                return(BadRequest());
            }

            var items = _storage.FindBy(
                new ReminderItemFilter(
                    datetimeUtc: filter.DateTime,
                    status: filter.Status
                    )
                );
            var models = items.Select(_ => new ReminderItemViewModel(_));

            return(Ok(models));
        }