public IHttpActionResult AddRules(AddRulesRequest addRulesRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var rules = new Rules() { RulesName = addRulesRequest.RulesName, RulesNo = addRulesRequest.RulesNo, Year = addRulesRequest.Year, PublicationDate = addRulesRequest.PublicationDate, CreatedBy = Utility.UserId }; int result = iRules.AddRules(rules); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Rules added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Rules alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding rules."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding rules."; Utility.WriteLog("AddRules", addRulesRequest, "Error while adding rules. (RulesAdminController)", ex.ToString()); } return(Ok(responses)); }
public IActionResult Add([FromBody] AddRulesRequest request) { return(Execute(() => _ruleService.AddRules(request))); }
/// <summary> /// 往转发规则组加入转发规则 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <AddRulesResponse> AddRules(AddRulesRequest request) { return(await new AddRulesExecutor().Client(this).Execute <AddRulesResponse, AddRulesResult, AddRulesRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 往转发规则组加入转发规则 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public AddRulesResponse AddRules(AddRulesRequest request) { return(new AddRulesExecutor().Client(this).Execute <AddRulesResponse, AddRulesResult, AddRulesRequest>(request)); }