Example #1
0
        public async Task <SeverityRuleViewModel> Present(SeverityRule model)
        {
            if (model.GeneralRule == null)
            {
                model = await _service.Get(model.Id);
            }

            return(new SeverityRuleViewModel(model.Id, model.GeneralRule.Name, model.GeneralRule.Description,
                                             model.GeneralRule.Matcher.ToString(), model.GeneralRule.StartAnchor, model.GeneralRule.EndAnchor,
                                             model.Trace.ToString(),
                                             model.Debug.ToString(), model.Info.ToString(), model.Warning.ToString(), model.Error.ToString(),
                                             model.Fatal.ToString()));
        }
        public async Task <ActionResult <SeverityRuleViewModel> > Get(int id)
        {
            try
            {
                var result = await _severityRuleService.Get(id);

                return(Ok(await _presenter.Present(result)));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(NotFound());
            }
            catch (Exception)
            {
                return(BadRequest($"Couldn't fetch severity rule with id {id}"));
            }
        }