コード例 #1
0
        public void Create([FromBody] PrivacyPolicyInsertCommand command)
        {
            bool IsResourceRequired = false;

            if (command.Target.Contains("\"Resource."))
            {
                IsResourceRequired = true;
            }

            var fieldRules = new List <FieldRule>();
            var target     = _conditionalExpressionService.Parse(command.Target);

            foreach (var rule in command.Rules)
            {
                var condition = _conditionalExpressionService.Parse(rule.Condition);
                var fieldRule = new FieldRule()
                {
                    Identifer    = rule.RuleID,
                    FieldEffects = rule.FieldEffects,
                    Condition    = condition
                };
                fieldRules.Add(fieldRule);

                if (!IsResourceRequired)
                {
                    IsResourceRequired = rule.Condition.Contains("\"Resource.");
                }
            }

            var policy = new PrivacyPolicy()
            {
                CollectionName = command.CollectionName,
                Description    = command.Description,
                PolicyId       = command.PolicyID,
                Rules          = fieldRules,
                IsAttributeResourceRequired = IsResourceRequired,
                Target = target
            };

            _privacyPolicyRepository.Add(policy);
        }
コード例 #2
0
 public int AddPrivacyPolicy(DLModel.PrivacyPolicy _privacy)
 {
     return(_privacyPolicyRepository.Add(_privacy).PrivacyPolicyID);
 }