Beispiel #1
0
        public void RuleAvailableInRepository()
        {
            var repository = new RulesRepository();

            Rules.AddTo(repository);
            Assert.That(repository.Get(RuleName), Is.Not.Null);
            Assert.That(repository.GetAll(), Has.One.Matches(Has.Property("Name").EqualTo(RuleName)));
        }
Beispiel #2
0
        public void DeleteRule(string id, string accessKey = null)
        {
            if (!AccessKeyHelper.CanAdminRules(accessKey))
            {
                Response.StatusCode = StatusCodes.Status401Unauthorized;
                return;
            }

            var ruleObj = RulesRepository.Get(id);

            if (ruleObj == null)
            {
                Response.StatusCode = StatusCodes.Status404NotFound;
                return;
            }

            RulesRepository.Delete(ruleObj);
        }
Beispiel #3
0
        public JArray GetRules(string accessKey = null)
        {
            if (!AccessKeyHelper.CanAdminRules(accessKey))
            {
                Response.StatusCode = StatusCodes.Status401Unauthorized;
                return(null);
            }

            var jArray = new JArray();

            foreach (var ruleObj in RulesRepository.Get())
            {
                var jObj = ruleObj.ToJObject();
                jArray.Add(jObj);
            }

            return(jArray);
        }