コード例 #1
0
        /// <summary>
        /// Renames the tenant.
        /// </summary>
        /// <param name="tenantName">Name of the tenant.</param>
        /// <param name="newName">The new name.</param>
        /// <exception cref="EntityNotFoundException"></exception>
        public static void RenameTenant(string tenantName, string newName)
        {
            using (new GlobalAdministratorContext( ))
            {
                /////
                // Check for existing tenant
                /////
                Tenant tenant = Find(tenantName);

                if (tenant == null)
                {
                    throw new EntityNotFoundException(string.Format(@"Tenant '{0}' not found.", tenantName));
                }

                tenant = tenant.AsWritable <Tenant>( );

                tenant.Name = newName;
                tenant.Save( );

                /////
                // Invalidate the tenant name to id cache
                /////
                TenantIdCache.Remove(tenantName);

                TenantNameCache.Remove(tenant.Id);
            }
        }