Пример #1
0
        private async Task save()
        {
            OnboardingStorage.EditedTimeEntry();

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

            var duration = await durationSubject.FirstAsync();

            var commonTimeEntryData = new EditTimeEntryDto
            {
                Id          = TimeEntryIds.First(),
                Description = Description.Value?.Trim() ?? string.Empty,
                StartTime   = startTimeSubject.Value,
                StopTime    = calculateStopTime(startTimeSubject.Value, duration),
                ProjectId   = projectId,
                TaskId      = taskId,
                Billable    = isBillableSubject.Value,
                WorkspaceId = workspaceId,
                TagIds      = tagIds.ToArray()
            };

            var timeEntriesDtos = timeEntries
                                  .Select(timeEntry => applyDataFromTimeEntry(commonTimeEntryData, timeEntry))
                                  .ToArray();

            interactorFactory
            .UpdateMultipleTimeEntries(timeEntriesDtos)
            .Execute()
            .SubscribeToErrorsAndCompletion((Exception ex) => close(), () => close())
            .DisposedBy(disposeBag);
        }
Пример #2
0
        private async Task save()
        {
            var reason = await isDirty()
                ? EditViewCloseReason.Save
                : EditViewCloseReason.SaveWithoutChange;

            OnboardingStorage.EditedTimeEntry();

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

            var duration = await durationSubject.FirstAsync();

            var commonTimeEntryData = new EditTimeEntryDto
            {
                Id          = TimeEntryIds.First(),
                Description = Description.Value?.Trim() ?? string.Empty,
                StartTime   = startTimeSubject.Value,
                StopTime    = calculateStopTime(startTimeSubject.Value, duration),
                ProjectId   = projectId,
                TaskId      = taskId,
                Billable    = isBillableSubject.Value,
                WorkspaceId = workspaceId,
                TagIds      = tagIds.ToArray()
            };

            var timeEntriesDtos = timeEntries
                                  .Select(timeEntry => applyDataFromTimeEntry(commonTimeEntryData, timeEntry))
                                  .ToArray();

            close(reason);

            await interactorFactory
            .UpdateMultipleTimeEntries(timeEntriesDtos)
            .Execute()
            .Catch(Observable.Empty <IEnumerable <IThreadSafeTimeEntry> >())
            .SubscribeOn(schedulerProvider.BackgroundScheduler);
        }