protected void UpdateTenant(string applicationName, string tenantName, Action<ApplicationTenantHeaderUpdateInfo> updateInfo)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException("applicationName");
            }
            if (string.IsNullOrEmpty(tenantName))
            {
                throw new ArgumentNullException("tenantName");
            }

            var repositoryService = InProcFactory.CreateInstance<ApplicationRepositoryService, IApplicationRepository>();
            try
            {
                var tenant = repositoryService.GetTenantHeaderInfo(applicationName, tenantName);
                if (tenant == null)
                {
                    throw new ArgumentException(string.Format("Tenant {0} from application {1} could not be found.", tenantName, applicationName));
                }

                var tenantUpdateInfo = new ApplicationTenantHeaderUpdateInfo()
                                           {
                                               ApplicationName = applicationName,
                                               Name = tenantName,
                                               IsActive = tenant.IsActive,
                                               ContractStartTime = tenant.ContractStartedAt,
                                               Url = tenant.Url
                                           };

                updateInfo(tenantUpdateInfo);

                repositoryService.UpdateTenantHeaderInfo(tenantUpdateInfo);
            }
            finally
            {
                InProcFactory.CloseProxy(repositoryService);
            }

        }
        public void UpdateTenantHeaderInfo(ApplicationTenantHeaderUpdateInfo tenantUpdateInfo)
        {

            UseDataContext(dataContext =>
                               {
                                   var dataTenant =
                                       dataContext.ApplicationTenants.FirstOrDefault(
                                           t => t.Application == tenantUpdateInfo.ApplicationName && t.TenantName == tenantUpdateInfo.Name);
                                   if (dataTenant == null)
                                   {
                                       throw new ArgumentException(string.Format("Tenant {0} from application {1} could not be found.", tenantUpdateInfo.Name, tenantUpdateInfo.ApplicationName));
                                   }

                                   dataTenant.Url = tenantUpdateInfo.Url;
                                   dataTenant.IsActive = tenantUpdateInfo.IsActive;
                                   dataTenant.ContractStartedAt = tenantUpdateInfo.ContractStartTime;

                                   dataContext.SubmitChanges();
                               });
        }