Hi,
The relationship between a document and a category is represented by the DocumentCategoryInfo class. So, you can use the DocumentCategoryInfoProvider.GetDocumentCategoryInfo method to determine if the given document has been assigned to the category. Please take a look at the following code snippet:
using CMS.SiteProvider;
using CMS.TreeEngine;
CategoryInfo myCategory = CategoryInfoProvider.GetCategoryInfo("TheCategory", "MySite");
DocumentCategoryInfo dcInfo = DocumentCategoryInfoProvider.GetDocumentCategoryInfo(CMSContext.CurrentDocument.DocumentID, myCategory.CategoryID);
if (dcInfo == null)
{
// document is not assigned to the category
}
Best regards,
Michal Legen