public IObservable <Unit> Execute()
 => interactorFactory.GetMultipleTimeEntriesById(ids)
 .Execute()
 .Select(timeEntries => timeEntries.Select(TimeEntry.DirtyDeleted))
 .SelectMany(dataSource.BatchUpdate)
 .SingleAsync()
 .Do(syncManager.InitiatePushSync)
 .SelectUnit();
Пример #2
0
        public override async Task Initialize(long[] timeEntryIds)
        {
            await base.Initialize(timeEntryIds);

            if (timeEntryIds == null || timeEntryIds.Length == 0)
            {
                throw new ArgumentException("Edit view has no Time Entries to edit.");
            }

            TimeEntryIds = timeEntryIds;

            var timeEntries = await interactorFactory.GetMultipleTimeEntriesById(TimeEntryIds).Execute();

            var timeEntry = timeEntries.First();

            originalTimeEntry = timeEntry;

            projectId = timeEntry.Project?.Id;
            taskId    = timeEntry.Task?.Id;
            workspaceIdSubject.OnNext(timeEntry.WorkspaceId);

            Description.Accept(timeEntry.Description);

            projectClientTaskSubject.OnNext(new ProjectClientTaskInfo(
                                                timeEntry.Project?.DisplayName(),
                                                timeEntry.Project?.DisplayColor(),
                                                timeEntry.Project?.Client?.Name,
                                                timeEntry.Task?.Name,
                                                timeEntry.Project?.IsPlaceholder() ?? false,
                                                timeEntry.Task?.IsPlaceholder() ?? false));

            isBillableSubject.OnNext(timeEntry.Billable);

            startTimeSubject.OnNext(timeEntry.Start);

            durationSubject.OnNext(timeEntry.TimeSpanDuration());

            GroupDuration = timeEntries.Sum(entry => entry.TimeSpanDuration());

            tagsSubject.OnNext(timeEntry.Tags?.ToImmutableList() ?? ImmutableList <IThreadSafeTag> .Empty);

            isInaccessibleSubject.OnNext(timeEntry.IsInaccessible);

            setupSyncError(timeEntries);
        }
Пример #3
0
        public IObservable <IEnumerable <IThreadSafeTimeEntry> > Execute()
        {
            var dtosMap = timeEntriesDtos.ToDictionary(dto => dto.Id);

            var ids = dtosMap.Keys.ToArray();

            return(interactorFactory.GetMultipleTimeEntriesById(ids)
                   .Execute()
                   .Select(timeEntries => timeEntries.Select(timeEntry => createUpdatedTimeEntry(timeEntry, dtosMap[timeEntry.Id])))
                   .SelectMany(dataSource.TimeEntries.BatchUpdate)
                   .UnwrapUpdatedThreadSafeEntities()
                   .Do(syncManager.InitiatePushSync));
        }
        public IObservable <IEnumerable <IThreadSafeTimeEntry> > Execute()
        {
            var updateTimeMeasurement = stopwatchProvider.Create(MeasuredOperation.UpdateTimeEntriesGroup);

            updateTimeMeasurement.Start();

            var dtosMap = timeEntriesDtos.ToDictionary(dto => dto.Id);

            var ids = dtosMap.Keys.ToArray();

            return(interactorFactory.GetMultipleTimeEntriesById(ids)
                   .Execute()
                   .Select(timeEntries => timeEntries.Select(timeEntry => createUpdatedTimeEntry(timeEntry, dtosMap[timeEntry.Id])))
                   .SelectMany(dataSource.TimeEntries.BatchUpdate)
                   .UnwrapUpdatedThreadSafeEntities()
                   .Do(syncManager.InitiatePushSync)
                   .Do(_ => updateTimeMeasurement.Stop()));
        }
Пример #5
0
            private void setupTest()
            {
                ids = new long[] { 4, 8, 15, 16, 23, 42 };

                interactorFactory = Substitute.For <IInteractorFactory>();

                var teInteractor = Substitute.For <IInteractor <IObservable <IEnumerable <IThreadSafeTimeEntry> > > >();
                var workspace    = Substitute.For <IThreadSafeWorkspace>();
                var tes          = Enumerable.Range(0, 5)
                                   .Select((_, index) => new MockTimeEntry(index, workspace))
                                   .ToList();
                var observable = Observable.Return(tes);

                teInteractor.Execute().Returns(observable);
                dataSource = Substitute.For <ITimeEntriesSource>();
                DataSource.TimeEntries.Returns(dataSource);

                interactorFactory
                .GetMultipleTimeEntriesById(Arg.Any <long[]>())
                .Returns(teInteractor);

                testedInteractor = new SoftDeleteMultipleTimeEntriesInteractor(DataSource.TimeEntries, SyncManager, interactorFactory, ids);
            }
 public IObservable <Unit> Execute()
 => interactorFactory.GetMultipleTimeEntriesById(ids).Execute()
 .SelectMany(dataSource.DeleteAll)
 .SelectUnit();