public async Task <MessageRuleViewModel> Present(MessageRule model) { if (model.GeneralRule == null) { model = await _service.Get(model.Id); } return(new MessageRuleViewModel(model.Id, model.GeneralRule.Name, model.GeneralRule.Description, model.GeneralRule.Matcher.ToString(), model.GeneralRule.StartAnchor, model.GeneralRule.EndAnchor, model.MaxLength, model.GeneralRuleId)); }
public async Task <ActionResult <MessageRuleViewModel> > Get(int id) { try { var result = await _messageRuleService.Get(id); return(Ok(await _presenter.Present(result))); } catch (ArgumentOutOfRangeException) { return(NotFound()); } catch (Exception) { return(BadRequest($"Couldn't fetch message rule with id {id}")); } }