Beispiel #1
0
        public SiriShortcutViewModel(SiriShortcut siriShortcut, IThreadSafeProject project = null)
        {
            if (siriShortcut.VoiceShortcut != null)
            {
                VoiceShortcut    = siriShortcut.VoiceShortcut;
                Type             = VoiceShortcut.Shortcut.Intent.ShortcutType();
                Title            = Type.Title();
                InvocationPhrase = VoiceShortcut.InvocationPhrase;
                IsActive         = true;

                Description   = siriShortcut.Parameters.Description;
                WorkspaceName = siriShortcut.Parameters.WorkspaceName;
                HasTags       = siriShortcut.Parameters.Tags != null;
                IsBillable    = siriShortcut.Parameters.Billable;

                ProjectName  = project?.Name;
                ClientName   = project?.Client?.Name;
                ProjectColor = project?.Color;

                if (Type == SiriShortcutType.CustomStart)
                {
                    Title = Description == null?Type.Title() : $"Start timer: { Description }";

                    IsCustomStart = true;
                }
            }
            else
            {
                Type     = siriShortcut.Type;
                Title    = Type.Title();
                IsActive = false;
            }
        }
        private IObservable <IThreadSafeProject> updateAtValue(IThreadSafeProject project)
        {
            var updatedProject = Project.Builder.From(project)
                                 .SetAt(timeService.CurrentDateTime)
                                 .Build();

            return(dataSource.Update(updatedProject));
        }
 public ProjectSuggestion(IThreadSafeProject project)
 {
     ProjectId     = project.Id;
     ProjectName   = project.Name;
     ProjectColor  = project.Color;
     NumberOfTasks = project.Tasks?.Count() ?? 0;
     ClientName    = project.Client?.Name ?? "";
     WorkspaceId   = project.WorkspaceId;
     WorkspaceName = project.Workspace?.Name ?? "";
     Tasks         = project.Tasks?.Select(task => new TaskSuggestion(Task.From(task))).ToList() ?? new List <TaskSuggestion>();
 }
        public static string DisplayColor(this IThreadSafeProject project)
        {
            switch (project.SyncStatus)
            {
            case Storage.SyncStatus.RefetchingNeeded:
                return(inaccessibleProjectColor);

            default:
                return(project.Color ?? "");
            }
        }
        public static string DisplayName(this IThreadSafeProject project)
        {
            var name = project.Name ?? "";

            switch (project.SyncStatus)
            {
            case Storage.SyncStatus.RefetchingNeeded:
                return(Resources.InaccessibleProject);

            default:
                return(project.Active ? name : $"{name} {Resources.ArchivedProjectDecorator}");
            }
        }
Beispiel #6
0
 public static Builder From(IThreadSafeProject project)
 => new Builder(project.Id)
 {
     Name            = project.Name,
     Color           = project.Color,
     Billable        = project.Billable,
     SyncStatus      = project.SyncStatus,
     WorkspaceId     = project.WorkspaceId,
     At              = project.At,
     ServerDeletedAt = project.ServerDeletedAt,
     IsDeleted       = project.IsDeleted,
     ClientId        = project.ClientId,
     Active          = project.Active
 };
Beispiel #7
0
 public MockTask(
     long id,
     IThreadSafeWorkspace workspace,
     IThreadSafeProject project,
     SyncStatus syncStatus = SyncStatus.InSync
     ) : this()
 {
     Id          = id;
     Workspace   = workspace;
     WorkspaceId = workspace.Id;
     Project     = project;
     ProjectId   = project.Id;
     SyncStatus  = syncStatus;
 }
 private static IThreadSafeTimeEntry createTimeEntry(
     DateTimeOffset start,
     IThreadSafeWorkspace workspace,
     string description,
     long duration,
     IThreadSafeProject project = null,
     IThreadSafeTask task       = null,
     IThreadSafeTag[] tags      = null,
     bool billable = false)
 => new MockTimeEntry
 {
     Start       = start,
     Workspace   = workspace,
     WorkspaceId = workspace.Id,
     Description = description,
     Duration    = duration,
     Project     = project,
     ProjectId   = project?.Id,
     Task        = task,
     TaskId      = task?.Id,
     Billable    = billable,
     Tags        = tags ?? Array.Empty <IThreadSafeTag>(),
     TagIds      = tags?.Select(tag => tag.Id) ?? new long[0]
 };
Beispiel #9
0
 public MockTimeEntry(
     long id,
     IThreadSafeWorkspace workspace,
     DateTimeOffset?start              = null,
     long?duration                     = null,
     IThreadSafeProject project        = null,
     IThreadSafeTask task              = null,
     IEnumerable <IThreadSafeTag> tags = null,
     SyncStatus syncStatus             = SyncStatus.InSync
     ) : this()
 {
     Id          = id;
     Workspace   = workspace;
     WorkspaceId = workspace.Id;
     Start       = start ?? default(DateTimeOffset);
     Duration    = duration;
     Project     = project;
     ProjectId   = project?.Id;
     Task        = task;
     TaskId      = task?.Id;
     Tags        = tags;
     TagIds      = tags?.Select(tag => tag.Id);
     SyncStatus  = syncStatus;
 }
 public static bool IsPlaceholder(this IThreadSafeProject project)
 => project?.SyncStatus == SyncStatus.RefetchingNeeded;
 private IObservable <IThreadSafeProject> notReferencedByAnyTimeEntryOrNull(IThreadSafeProject project)
 => timeEntriesDataSource.GetAll(timeEntry => timeEntry.ProjectId == project.Id)
 .Select(referencingTimeEntries => referencingTimeEntries.Any())
 .Select(isReferencedByAnyTimeEntry => isReferencedByAnyTimeEntry ? null : project);
Beispiel #12
0
 private ProjectSpan(IThreadSafeProject project, IThreadSafeTask task)
     : this(task.ProjectId, project.Name, project.Color, task.Id, task.Name)
 {
 }
Beispiel #13
0
 public ProjectSpan(IThreadSafeProject project)
     : this(project.Id, project.Name, project.Color)
 {
 }