// POST: odata/RuleVariables public async Task <IHttpActionResult> Post(RuleVariable ruleVariable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repository.RuleVariables.Add(ruleVariable); try { await _repository.SaveChangesAsync(); } catch (DbUpdateException) { if (RuleVariableExists(ruleVariable.Id)) { return(Conflict()); } else { throw; } } return(Created(ruleVariable)); }
public static RuleVariable CreateRuleVariable(int ID, string name, bool state) { RuleVariable ruleVariable = new RuleVariable(); ruleVariable.Id = ID; ruleVariable.Name = name; ruleVariable.State = state; return(ruleVariable); }
// DELETE: odata/RuleVariables(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { RuleVariable ruleVariable = await _repository.RuleVariables.FindAsync(key); if (ruleVariable == null) { return(NotFound()); } _repository.RuleVariables.Remove(ruleVariable); await _repository.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/RuleVariables(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <RuleVariable> patch) { Validate(patch.GetInstance()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RuleVariable ruleVariable = await _repository.RuleVariables.FindAsync(key); if (ruleVariable == null) { return(NotFound()); } patch.Put(ruleVariable); try { await _repository.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RuleVariableExists(key)) { return(NotFound()); } else { throw; } } return(Updated(ruleVariable)); }
private static RuleVariable GenerateRuleVariable() { var ruleVariable = RuleVariable.CreateRuleVariable(0, "My Rule Variable", false); return(ruleVariable); }