コード例 #1
0
        public async Task <ActionResult <CustomAttributeRuleViewModel> > Create([FromBody] CustomAttributeRuleViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            var customAttributeRuleRequest = await _presenter.Request(model);

            try
            {
                var created = await _service.Create(customAttributeRuleRequest);

                return(CreatedAtAction(nameof(Create), await _presenter.Present(created)));
            }
            catch (Exception debug)
            {
                return(BadRequest("Failed to create message rule"));
            }
        }
コード例 #2
0
        public async Task <ActionResult <CustomAttributeRuleViewModel> > Edit(int id,
                                                                              [FromBody] CustomAttributeRuleViewModel model)
        {
            if (model == null || model.Id != id)
            {
                return(BadRequest());
            }

            try
            {
                var customAttributeRule = await _presenter.Request(model);

                var updatedCustomAttributeRule = await _service.Edit(customAttributeRule);

                return(Ok(await _presenter.Present(updatedCustomAttributeRule)));
            }
            catch
            {
                return(BadRequest("Failed to edit custom attribute rule"));
            }
        }
 public ParseRequestCustomAttributeRuleViewModel(string line, CustomAttributeRuleViewModel ruleViewModel)
 {
     Line          = line;
     RuleViewModel = ruleViewModel;
 }