public static bool FindAnyTeam(ClientSampleContext context, Guid?projectId, out WebApiTeamRef team)
        {
            if (!projectId.HasValue)
            {
                TeamProjectReference project;
                if (FindAnyProject(context, out project))
                {
                    projectId = project.Id;
                }
            }

            // Check if we already have a team that has been cached for this project
            if (!context.TryGetValue <WebApiTeamRef>("$" + projectId + "Team", out team))
            {
                TeamHttpClient teamClient = context.Connection.GetClient <TeamHttpClient>();

                using (new ClientSampleHttpLoggerOutputSuppression())
                {
                    team = teamClient.GetTeamsAsync(projectId.ToString(), top: 1).Result.FirstOrDefault();
                }

                if (team != null)
                {
                    context.SetValue <WebApiTeamRef>("$" + projectId + "Team", team);
                }
                else
                {
                    // create a team?
                    throw new Exception("No team available for running this sample.");
                }
            }

            return(team != null);
        }
        public static bool FindAnyProject(ClientSampleContext context, out TeamProjectReference project)
        {
            // Check if we already have a default project loaded
            if (!context.TryGetValue <TeamProjectReference>("$defautProject", out project))
            {
                VssConnection     connection    = context.Connection;
                ProjectHttpClient projectClient = connection.GetClient <ProjectHttpClient>();

                using (new ClientSampleHttpLoggerOutputSuppression())
                {
                    // Check if an ID was already set (this could have been provided by the caller)
                    Guid projectId;
                    if (!context.TryGetValue <Guid>("projectId", out projectId))
                    {
                        // Get the first project
                        project = projectClient.GetProjects(null, top: 1).Result.FirstOrDefault();
                    }
                    else
                    {
                        // Get the details for this project
                        project = projectClient.GetProject(projectId.ToString()).Result;
                    }
                }

                if (project != null)
                {
                    context.SetValue <TeamProjectReference>("$defautProject", project);
                }
                else
                {
                    // create a project here?
                    throw new Exception("No projects available for running the sample.");
                }
            }

            return(project != null);
        }