private IObservable <Unit> done() { var timeEntry = textFieldInfo.Value.AsTimeEntryPrototype(startTime, duration, isBillable.Value); var origin = duration.HasValue ? TimeEntryStartOrigin.Manual : TimeEntryStartOrigin.Timer; if (parameter.Origin is TimeEntryStartOrigin paramOrigin) { origin = paramOrigin; } return(interactorFactory.CreateTimeEntry(timeEntry, origin).Execute() .Do(_ => navigationService.Close(this)) .SelectUnit()); }
private IObservable <IThreadSafeTimeEntry> done() { var timeEntry = textFieldInfo.Value.AsTimeEntryPrototype(startTime, duration, isBillable.Value); var origin = duration.HasValue ? TimeEntryStartOrigin.Manual : TimeEntryStartOrigin.Timer; if (parameter.Origin is TimeEntryStartOrigin paramOrigin) { origin = paramOrigin; } Close(); return(interactorFactory.CreateTimeEntry(timeEntry, origin) .Execute() .SubscribeOn(schedulerProvider.BackgroundScheduler)); }
public void Init(string action, string description) { urlNavigationAction = action; if (!string.IsNullOrEmpty(description)) { interactorFactory.GetDefaultWorkspace() .TrackException <InvalidOperationException, IThreadSafeWorkspace>("MainViewModel.Init") .Execute() .SelectMany(workspace => interactorFactory .CreateTimeEntry(description.AsTimeEntryPrototype(TimeService.CurrentDateTime, workspace.Id)) .Execute()) .Subscribe() .DisposedBy(disposeBag); } }
public static async Task Create(this DeeplinkCreateTimeEntryParameters parameters, IInteractorFactory interactorFactory) { var workspaceId = parameters.WorkspaceId; if (!workspaceId.HasValue) { var defaultWorkspace = await interactorFactory.GetDefaultWorkspace().Execute(); workspaceId = defaultWorkspace.Id; } var startTime = parameters.StartTime; if (!startTime.HasValue) { return; } var stopTime = parameters.StopTime; var duration = parameters.Duration; if (!duration.HasValue && !stopTime.HasValue) { return; } if (!duration.HasValue) { duration = stopTime.Value - startTime.Value; } var description = parameters.Description ?? string.Empty; var projectId = parameters.ProjectId; var taskId = parameters.TaskId; var tagIds = parameters.TagIds; var isBillable = parameters.IsBillable ?? false; var source = parameters.StartSource ?? TimeEntryStartOrigin.Deeplink; var prototype = description.AsTimeEntryPrototype(startTime.Value, workspaceId.Value, duration, projectId, taskId, tagIds, isBillable); await interactorFactory.CreateTimeEntry(prototype, source).Execute(); }
public static async Task Start(this DeeplinkStartTimeEntryParameters parameters, IInteractorFactory interactorFactory, ITimeService timeService) { var workspaceId = parameters.WorkspaceId; if (!workspaceId.HasValue) { var defaultWorkspace = await interactorFactory.GetDefaultWorkspace().Execute(); workspaceId = defaultWorkspace.Id; } var description = parameters.Description ?? string.Empty; var startTime = parameters.StartTime ?? timeService.CurrentDateTime; var projectId = parameters.ProjectId; var taskId = parameters.TaskId; var tagIds = parameters.TagIds; var isBillable = parameters.IsBillable ?? false; var source = parameters.Source ?? TimeEntryStartOrigin.Deeplink; var prototype = description.AsTimeEntryPrototype(startTime, workspaceId.Value, null, projectId, taskId, tagIds, isBillable); await interactorFactory.CreateTimeEntry(prototype, source).Execute(); }