コード例 #1
0
        private void UpdateRelationships(Guid?projectId)
        {
            // Ensure that this content runs in UI thread
            ServiceContainer.Resolve <IPlatformUtils> ().DispatchOnUIThread(async() => {
                if (projectId != Guid.Empty)
                {
                    data.ProjectId = projectId;
                }
                else
                {
                    data.ProjectId = null;
                }

                if (data.ProjectId.HasValue)
                {
                    var project = await TimeEntryModel.GetProjectDataAsync(data.ProjectId.Value);
                    ProjectName = project.Name;
                    if (project.ClientId.HasValue)
                    {
                        var client = await TimeEntryModel.GetClientDataAsync(project.ClientId.Value);
                        ClientName = client.Name;
                    }
                    else
                    {
                        ClientName = string.Empty;
                    }

                    // TODO: Workspace and Billable should change!
                    data.WorkspaceId = project.WorkspaceId;
                    data.IsBillable  = project.IsBillable;
                    var workspace    = await TimeEntryModel.GetWorkspaceDataAsync(project.WorkspaceId);
                    IsPremium        = workspace.IsPremium;

                    WorkspaceId = data.WorkspaceId;
                    IsBillable  = data.IsBillable;
                }
                else
                {
                    ProjectName = string.Empty;
                    ClientName  = string.Empty;
                }
            });
        }
コード例 #2
0
        private void UpdateRelationships(Guid?projectId)
        {
            // Ensure that this content runs in UI thread
            ServiceContainer.Resolve <IPlatformUtils> ().DispatchOnUIThread(async() => {
                var workspace = await TimeEntryModel.GetWorkspaceDataAsync(data.WorkspaceId);

                if (projectId != Guid.Empty)
                {
                    data.ProjectId = projectId;
                }
                else
                {
                    data.ProjectId = null;
                }

                if (data.ProjectId.HasValue)
                {
                    var project     = await TimeEntryModel.GetProjectDataAsync(data.ProjectId.Value);
                    ProjectName     = project.Name;
                    ProjectColorHex = ProjectModel.HexColors [project.Color % ProjectModel.HexColors.Length];

                    if (project.ClientId.HasValue)
                    {
                        var client = await TimeEntryModel.GetClientDataAsync(project.ClientId.Value);
                        ClientName = client.Name;
                    }
                    else
                    {
                        ClientName = string.Empty;
                    }

                    if (data.TaskId.HasValue)
                    {
                        var task = await TimeEntryModel.GetTaskDataAsync(data.TaskId.Value);
                        TaskName = task.Name;
                    }
                    else
                    {
                        TaskName = string.Empty;
                    }

                    // TODO: Workspace, Billable and Tags should change!?
                    if (data.WorkspaceId != project.WorkspaceId)
                    {
                        data.WorkspaceId = project.WorkspaceId;
                        workspace        = await TimeEntryModel.GetWorkspaceDataAsync(project.WorkspaceId);
                        data.IsBillable  = workspace.IsPremium ? IsBillable : false;
                        TagList          = await UpdateTagsWithWorkspace(data.Id, data.WorkspaceId, TagList);
                    }
                }
                else
                {
                    ProjectName     = string.Empty;
                    ClientName      = string.Empty;
                    TaskName        = string.Empty;
                    ProjectColorHex = ProjectModel.HexColors [ProjectModel.DefaultColor];
                }

                IsBillable  = data.IsBillable;
                WorkspaceId = data.WorkspaceId;
                IsPremium   = workspace.IsPremium;
            });
        }