private async Task <IDatabasePreferences> updatePreferences(EditPreferencesDTO preferencesDto) { var newPreferences = await dataSource.Preferences.Update(preferencesDto); dataSource.SyncManager.PushSync(); return(newPreferences); }
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; }
public async Task toggleUseTwentyFourHourClock() { UseTwentyFourHourClock = !UseTwentyFourHourClock; var timeFormat = UseTwentyFourHourClock ? TimeFormat.TwentyFourHoursFormat : TimeFormat.TwelveHoursFormat; var preferencesDto = new EditPreferencesDTO { TimeOfDayFormat = timeFormat }; await updatePreferences(preferencesDto); }
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(); }
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(); }
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; }
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(); }
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); }
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);
public IInteractor <IObservable <IThreadSafePreferences> > UpdatePreferences(EditPreferencesDTO preferencesDto) => new UpdatePreferencesInteractor(dataSource.Preferences, preferencesDto);