Is there a way to check the template ID of a Sitecore item with glass mapper?
My business logic would do the following:
- Get the context item
- If the context item has specific template it is OK
- If it has a different template, then find another item with that template according to some business rules which also check the template
I would like to use the SitecoreContext
class, described here: http://www.glass.lu/Mapper/Sc/Documentation/ISitecoreContext
My code looks like this:
var context = new SitecoreContext();
var currentItem = context.GetCurrentItem<MyModel>();
if(HasCorrectTemplate(currentItem))
{
return currentItem;
}
return GetFallbackItem();
I don't really want to customize Glass Mapper for this, since it seems to me it should be a basic feature to check the template ID.
I can only think of using some kind of tricky query for this and I didn't find documentation about an other possibility.