Example #1
0
        private async Task UpdateTasksAsync(IEnumerable <GetScheduledTaskDTO> tasks)
        {
            foreach (var task in tasks)
            {
                var dbTask = await _dataHelper.GetByIdAsync(task.Id);

                if (task.IsDeleted)
                {
                    await _dataHelper.DeleteAsync(task.Id);

                    if (dbTask != null)
                    {
                        _alarmHelper.CancelAlarm(dbTask);
                    }
                }
                else if (dbTask == null)
                {
                    var newTask = MapToEntity(task);

                    await _dataHelper.InsertAsync(newTask);

                    _alarmHelper.SetAlarm(newTask);
                }
                else
                {
                    var updatedTask = MapToEntity(task, dbTask);

                    await _dataHelper.UpdateAsync(updatedTask);

                    _alarmHelper.UpdateAlarm(updatedTask);
                }
            }
        }
Example #2
0
        private void UpdateAlarm()
        {
            if (_scheduledTask.Start <= DateTime.Now)
            {
                return;
            }

            _alarmHelper.UpdateAlarm(_scheduledTask);
        }