public HttpResponseMessage ValidateProject(int projectId, int connectionId = 0)
        {
            try
            {
                var project = _projectFactory.CreateProject(projectId);
                Connection connection;
                if (connectionId == 0)
                {
                    connection = _dataRepository.ConnectionRepository
                        .GetDataByProjectId(projectId)
                        .FirstOrDefault(x => x.IsActive & x.IsDefault & x.ProjectId == projectId);
                    if (connection != null)
                    {
                        connection.ConnectionProvider =
                            _dataRepository.ConnectionProviderRepository.GetDataById(connection.ConnectionProviderId)
                                .FirstOrDefault();
                        connectionId = connection.ConnectionId;
                    }
                }
                else
                {
                    connection = _connectionFactory.CreateConnection(connectionId);
                }

                var validationProject = new ValidationProject(_dataRepository, projectId);
                if (!validationProject.ValidateConnection(connectionId))
                    throw new Exception(ConnectionNotValid);

                foreach (var test in project.Tests)
                {
                    validationProject.ValidationTests.Add(new ValidationTest(connection, test));
                }
                foreach (var testGroup in project.TestGroups)
                {
                    validationProject.ValidationTestGroups.Add(new ValidationTestGroup(connection, testGroup));
                }


                var valCollection = validationProject.Validate();
                PersistValidationResults(valCollection, null, projectId);
                return Request.CreateResponse(HttpStatusCode.OK, validationProject);
            }
            catch (Exception ex)
            {
                return
                    Request.CreateErrorResponse(
                        ex.Message == ConnectionNotValid
                            ? HttpStatusCode.BadRequest
                            : HttpStatusCode.InternalServerError, new HttpError(ex.Message));
            }
        }