Exemplo n.º 1
0
        protected override void InternalHasValidationResult(EntityValidationFacade validationFacade, KeyValuePair <string, List <dynamic> > properties)
        {
            // If there are already critical errors that apply to the property, no further validation is performed.
            if (validationFacade.ValidationResults.Any(v => v.Node == validationFacade.RequestResource.Id && v.Path == properties.Key && v.ResultSeverity == ValidationResultSeverity.Violation))
            {
                return;
            }

            // Only consumer groups that are active and for which the current user has the appropriate rights will be returned.
            // Therefore, the next step checks if a forbidden consumer group is used.
            var activeConsumerGroups = _consumerGroupService.GetActiveEntities();

            foreach (var propertyValue in properties.Value)
            {
                if (propertyValue is null)
                {
                    continue;
                }

                if (activeConsumerGroups.All(cg => cg.Id != propertyValue))
                {
                    validationFacade.ValidationResults.Add(new ValidationResultProperty(validationFacade.RequestResource.Id, properties.Key, propertyValue, string.Format(Common.Constants.Messages.Resource.ForbiddenConsumerGroup, propertyValue), ValidationResultSeverity.Violation));
                }
            }
            ;
        }
        public IActionResult GetActiveConsumerGroups()
        {
            var consumerGroups = _consumerGroupService.GetActiveEntities();

            return(Ok(consumerGroups));
        }