public async Task <RuleApiModel> PutAsync( [FromRoute] string id, [FromBody] RuleApiModel rule) { if (rule == null) { throw new InvalidInputException("Rule not provided in request body."); } //Ensure the id on the model matches the route rule.Id = id; Rule updatedRule = await this.ruleService.UpsertIfNotDeletedAsync(rule.ToServiceModel()); return(new RuleApiModel(updatedRule, false)); }
public async Task <RuleApiModel> PostAsync( [FromQuery] string template, [FromBody] RuleApiModel rule) { if (!string.IsNullOrEmpty(template)) { // create rules from template await this.ruleService.CreateFromTemplateAsync(template); return(null); } // create rule from request body if (rule == null) { throw new InvalidInputException("Rule not provided in request body."); } Rule newRule = await this.ruleService.CreateAsync(rule.ToServiceModel()); return(new RuleApiModel(newRule, false)); }