public GetTeamCityProjectDetailsResponse Get(GetTeamCityProjectDetails request)
        {
            GetProjectResponse teamCityResponse = null;

            try
            {
                teamCityResponse = TeamCityClient.GetProject(new GetProject
                {
                    Locator = "id:" + request.ProjectId
                });
            }
            catch (WebServiceException e)
            {
                if (e.IsAny400())
                {
                    throw HttpError.NotFound("Project not found");
                }
            }

            if (teamCityResponse == null)
            {
                throw new HttpError(HttpStatusCode.InternalServerError, "Invalid response from TeamCity");
            }

            GetBuildResponse build = null;

            try
            {
                build = TeamCityClient.GetBuild(new GetBuild {
                    BuildLocator = "project:id:" + request.ProjectId
                });
            }
            catch (WebException e)
            {
                if (!e.HasStatus(HttpStatusCode.BadRequest))
                {
                    throw;
                }
            }
            catch (WebServiceException wse)
            {
                if (!wse.IsAny400())
                {
                    throw;
                }
            }

            build = build ?? new GetBuildResponse();

            var response = new GetTeamCityProjectDetailsResponse
            {
                ProjectName = teamCityResponse.Name,
                ProjectId   = teamCityResponse.Id,
                BuildNumber = build.Number,
                BuildState  = build.State,
                BuildStatus = build.StatusText
            };

            return(response);
        }
        public GetTeamCityProjectDetailsResponse Get(GetTeamCityProjectDetails request)
        {
            GetProjectResponse teamCityResponse = null;
            try
            {
                teamCityResponse = TeamCityClient.GetProject(new GetProject
                {
                    Locator = "id:" + request.ProjectId
                });
            }
            catch (WebServiceException e)
            {
                if (e.IsAny400())
                {
                    throw HttpError.NotFound("Project not found");
                }
            }

            if (teamCityResponse == null)
            {
                throw new HttpError(HttpStatusCode.InternalServerError, "Invalid response from TeamCity");
            }

            GetBuildResponse build = null;
            try
            {
                build = TeamCityClient.GetBuild(new GetBuild {BuildLocator = "project:id:" + request.ProjectId});
            }
            catch (WebException e)
            {
                if (!e.HasStatus(HttpStatusCode.BadRequest))
                    throw;
            }
            catch (WebServiceException wse)
            {
                if (!wse.IsAny400())
                    throw;
            }

            build = build ?? new GetBuildResponse();

            var response = new GetTeamCityProjectDetailsResponse
            {
                ProjectName = teamCityResponse.Name,
                ProjectId = teamCityResponse.Id,
                BuildNumber = build.Number,
                BuildState = build.State,
                BuildStatus = build.StatusText
            };
            return response;
        }