Beispiel #1
0
        public void RuleServiceTest_Add_valid()
        {
            var model = new RuleModel
            {
                RuleId   = 1,
                Category = "Category",
                Text     = "Text",
                Title    = "Title"
            };
            var expected = rep.Add(model);
            var actual   = service.Add(model);

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public IActionResult Create([FromBody] EditRuleNameResource resource)
        {
            AppLogger.LogResourceRequest(nameof(Create), base.GetUsernameForRequest());

            try
            {
                var result = _ruleService.ValidateResource(resource);

                if (!result.IsValid)
                {
                    GetErrorsForModelState(result.ErrorMessages);
                }

                if (ModelState.IsValid)
                {
                    _ruleService.Add(resource);

                    return(CreatedAtAction(nameof(Create), resource));
                }

                return(ValidationProblem());
            }
            catch (Exception ex)
            {
                return(BadRequestExceptionHandler(ex, nameof(Create)));
            }
        }
        public void RuleControllerTest_AddRule()
        {
            var expected = service.Add(new RuleModel());
            var actual   = controller.AddRule(new RuleModel());

            Assert.AreEqual(expected, actual);
        }
        public void Create([FromBody] EditRuleDTO editRuleDTO)
        {
            try
            {
                var result = _ruleService.ValidateResource(editRuleDTO);
                if (!result.IsValid)
                {
                }

                if (result.IsValid)
                {
                    _ruleService.Add(editRuleDTO);
                }
            }
            catch (Exception)
            {
                // Implement logging MS
                //throw StatusCode(500, "Internal server error");
            }
        }
Beispiel #5
0
        public IActionResult Add([FromBody] ApplyRuleModel model)
        {
            var result = _ruleService.Add(model);

            return(ResultFromService(result));
        }
Beispiel #6
0
        public void Add(RuleModel model)
        {
            var dto = _mapper.Map <RuleDto>(model);

            _ruleService.Add(dto);
        }
Beispiel #7
0
 public bool AddRule(RuleModel rule)
 {
     return(service.Add(rule));
 }