private string findAvailableContentTypeName(SPWeb web)
{
string candidate = SampleData.GetSampleValueRandom(SampleData.BusinessDocsTypes);
bool alreadyExists = false;
foreach (SPContentType ct in web.ContentTypes)
{
if (ct.Name == candidate)
{
alreadyExists = true;
}
}
if (alreadyExists)
{
return findAvailableContentTypeName(web);
}
else
{
return candidate;
}
}