public SubscriptionLevelPartSettings GetSettings(SubscriptionLevelPart subscriptionLevelPart) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(subscriptionLevelPart.ContentItem.ContentType); var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(SubscriptionLevelPart), StringComparison.Ordinal)); return(contentTypePartDefinition.GetSettings <SubscriptionLevelPartSettings>()); }
public async Task <List <SubscriptionGroupPart> > GetAsync(SubscriptionLevelPart group, bool allowMultiple) { var subscriptions = await _subscriptionsService.GetAllAsync(); if (subscriptions == null) { return(null); } var results = new List <SubscriptionGroupPart>(); foreach (var subscription in subscriptions) { if (allowMultiple && !group.SubscriptionSelection.Any(x => x.Identifier == subscription.Identifier && x.IsSelected)) { continue; } if (!allowMultiple && group.Subscription != subscription.Identifier) { continue; } results.Add(new SubscriptionGroupPart { ContentItem = subscription.ContentItem.As <SubscriptionGroupSelectPart>().ContentItem, Identifier = subscription.ContentItem.As <SubscriptionGroupSelectPart>().SubscriptionGroup }); } return(results); }
private bool HasAccessToSubscriptionLevel(SubscriptionPart[] subscriptionAccessSelection, SubscriptionLevelPart group, bool allowMultiple) { // Check subsciption on single subscription level if (!allowMultiple && !subscriptionAccessSelection.Any(x => x.Identifier == group.Subscription)) { return(false); } // Check subsciption on multiple subscription level if (allowMultiple && !subscriptionAccessSelection.Any(x => group.SubscriptionSelection.Any(y => y.Identifier == x.Identifier && y.IsSelected))) { return(false); } return(true); }