Example #1
0
        private async Task <IDatabasePreferences> updatePreferences(EditPreferencesDTO preferencesDto)
        {
            var newPreferences = await dataSource.Preferences.Update(preferencesDto);

            dataSource.SyncManager.PushSync();
            return(newPreferences);
        }
Example #2
0
 public IObservable <IDatabasePreferences> Update(EditPreferencesDTO dto)
 => storage
 .Single()
 .Select(preferences => updatedPreferences(preferences, dto))
 .SelectMany(storage.Update)
 .Select(Preferences.From)
 .Do(currentPreferencesSubject.OnNext);
        public UpdatePreferencesInteractor(ISingletonDataSource <IThreadSafePreferences> dataSource, EditPreferencesDTO dto)
        {
            Ensure.Argument.IsNotNull(dto, nameof(dto));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));

            this.dto        = dto;
            this.dataSource = dataSource;
        }
Example #4
0
        public async Task toggleUseTwentyFourHourClock()
        {
            UseTwentyFourHourClock = !UseTwentyFourHourClock;
            var timeFormat = UseTwentyFourHourClock
                ? TimeFormat.TwentyFourHoursFormat
                : TimeFormat.TwelveHoursFormat;

            var preferencesDto = new EditPreferencesDTO {
                TimeOfDayFormat = timeFormat
            };

            await updatePreferences(preferencesDto);
        }
Example #5
0
        private async Task updatePreferences(
            New <DurationFormat> durationFormat = default(New <DurationFormat>),
            New <DateFormat> dateFormat         = default(New <DateFormat>),
            New <TimeFormat> timeFormat         = default(New <TimeFormat>))
        {
            var preferencesDto = new EditPreferencesDTO
            {
                DurationFormat  = durationFormat,
                DateFormat      = dateFormat,
                TimeOfDayFormat = timeFormat
            };

            await dataSource.Preferences.Update(preferencesDto);

            dataSource.SyncManager.PushSync();
        }
Example #6
0
        private async Task updatePreferences(
            New <DurationFormat> durationFormat = default(New <DurationFormat>),
            New <DateFormat> dateFormat         = default(New <DateFormat>),
            New <TimeFormat> timeFormat         = default(New <TimeFormat>))
        {
            var preferencesDto = new EditPreferencesDTO
            {
                DurationFormat  = durationFormat,
                DateFormat      = dateFormat,
                TimeOfDayFormat = timeFormat
            };

            await interactorFactory.UpdatePreferences(preferencesDto).Execute();

            dataSource.SyncManager.InitiatePushSync();
        }
Example #7
0
        private async Task selectDurationFormat()
        {
            var newDurationFormat = await navigationService
                                    .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(DurationFormat);

            if (DurationFormat == newDurationFormat)
            {
                return;
            }

            var preferencesDto = new EditPreferencesDTO {
                DurationFormat = newDurationFormat
            };
            var newPreferences = await updatePreferences(preferencesDto);

            DurationFormat = newPreferences.DurationFormat;
        }
Example #8
0
        private async Task updatePreferences(
            New <DurationFormat> durationFormat = default(New <DurationFormat>),
            New <DateFormat> dateFormat         = default(New <DateFormat>),
            New <TimeFormat> timeFormat         = default(New <TimeFormat>),
            New <bool> collapseTimeEntries      = default(New <bool>))
        {
            var preferencesDto = new EditPreferencesDTO
            {
                DurationFormat      = durationFormat,
                DateFormat          = dateFormat,
                TimeOfDayFormat     = timeFormat,
                CollapseTimeEntries = collapseTimeEntries
            };

            await interactorFactory.UpdatePreferences(preferencesDto).Execute();

            syncManager.InitiatePushSync();
        }
Example #9
0
            public Builder SetFrom(EditPreferencesDTO dto)
            {
                if (dto.DateFormat.HasValue)
                {
                    DateFormat = dto.DateFormat.Value;
                }

                if (dto.DurationFormat.HasValue)
                {
                    DurationFormat = dto.DurationFormat.Value;
                }

                if (dto.TimeOfDayFormat.HasValue)
                {
                    TimeOfDayFormat = dto.TimeOfDayFormat.Value;
                }

                if (dto.CollapseTimeEntries.HasValue)
                {
                    CollapseTimeEntries = dto.CollapseTimeEntries.Value;
                }

                return(this);
            }
Example #10
0
 private IDatabasePreferences updatedPreferences(IDatabasePreferences existing, EditPreferencesDTO dto)
 => Preferences.Builder
 .FromExisting(existing)
 .SetFrom(dto)
 .SetSyncStatus(SyncStatus.SyncNeeded)
 .Build();
 private IThreadSafePreferences updatedPreferences(IThreadSafePreferences existing, EditPreferencesDTO dto)
 => existing.With(
     dateFormat: dto.DateFormat,
     durationFormat: dto.DurationFormat,
     timeOfDayFormat: dto.TimeOfDayFormat,
     collapseTimeEntries: dto.CollapseTimeEntries,
     syncStatus: SyncStatus.SyncNeeded
     );
 public IObservable <IThreadSafePreferences> Update(EditPreferencesDTO dto)
 => Get()
 .Select(preferences => updatedPreferences(preferences, dto))
 .SelectMany(Update);
Example #13
0
 public IInteractor <IObservable <IThreadSafePreferences> > UpdatePreferences(EditPreferencesDTO preferencesDto)
 => new UpdatePreferencesInteractor(dataSource.Preferences, preferencesDto);