I've created a Business Area module in module builder with Business Units as a child type. I've also created a Services module in module builder and created a dynamic items field control selector for it. On the Business Unit module, I've added a Guid[] field and am using the Services selector to associated services.
I've set up a couple pages in Sitefinity, a page with a Services list widget on it and another page that has a Services details widget on it, the list points to the details page. On the Services details widget template, I'm including a custom control that uses the below code to look up the Service via the url name, then it looks up the Business Units and checks if any of them are associated to the Service.
protected void Page_Load(object sender, EventArgs e)
{
RouteHelper.SetUrlParametersResolved();
string urlParams = this.GetUrlParameterString(true);
if (!string.IsNullOrEmpty(urlParams))
{
urlParams = urlParams.Replace("/", string.Empty);
var dynamicModuleManager = DynamicModuleManager.GetManager(string.Empty);
var serviceType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Services.Service");
var service = dynamicModuleManager.GetDataItems(serviceType).FirstOrDefault(s => s.Status == ContentLifecycleStatus.Live && s.UrlName == urlParams);
if (service != null)
{
var businessUnits = GetBusinessUnits().Where(bu => bu.GetValue<Guid[]>("Services").Contains(service.OriginalContentId));
foreach (var bu in businessUnits)
{
//do something cool
}
}
}
}
public IQueryable<DynamicContent>GetBusinessUnits()
{
var providerName = String.Empty;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type businessUnitType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.BusinessAreas.BusinessUnit");
var myCollection = dynamicModuleManager.GetDataItems(businessUnitType).Where(bu => bu.Status == ContentLifecycleStatus.Live);
return myCollection;
}