public BuildServer AddBuildServer(BuildServer buildServer)
        {
            Touch();

            buildServer.Id = Interlocked.Increment(ref nextBuildServerId);

            buildServerMap[buildServer.Id] = buildServer;

            return buildServer;
        }
        public bool DeleteBuildServer(BuildServer buildServer)
        {
            using (var dataContext = dataContextFactory.Create())
            {
                dataContext.BuildServers.DeleteOnSubmit(
                    dataContext.BuildServers.First(s => s.Id == buildServer.Id));

                dataContext.SubmitChanges();

                Touch();

                return true;
            }
        }
        public BuildServer AddBuildServer(BuildServer buildServer)
        {
            using (var dataContext = dataContextFactory.Create())
            {
                var entity = BuildServerEntity.FromBuildServer(buildServer, credentialEncryptor);
                dataContext.BuildServers.InsertOnSubmit(entity);

                dataContext.SubmitChanges();

                Touch();

                return entity.ToBuildServer(credentialEncryptor);
            }
        }
        public bool DeleteBuildServer(BuildServer buildServer)
        {
            if (buildServerMap.Remove(buildServer.Id))
            {
                foreach (Job job in jobMap.Values.ToList().Where(j => j.BuildServer.Id == buildServer.Id))
                {
                    jobMap.Remove(job.Id);
                }

                Touch();

                return true;
            }
            else
            {
                return false;
            }
        }
 public ICollection<Job> GetJobs(BuildServer buildServer)
 {
     using (var dataContext = dataContextFactory.Create())
     {
         return dataContext.Jobs
             .Where(j => j.BuildServerId == buildServer.Id)
             .Select(j => j.ToJob(buildServer))
             .ToList();
     }
 }
 public ICollection<Job> GetJobs(BuildServer buildServer)
 {
     return jobMap.Values
         .Where(j => j.BuildServer == buildServer)
         .ToList();
 }