public IHttpActionResult PostCalcHistory(CalcHistory calcHistory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } calcHistory.UpdateDate = DateTime.Now; db.CalcHistory.Add(calcHistory); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = calcHistory.ID }, calcHistory); }
public IHttpActionResult PutCalcHistory(int id, CalcHistory calcHistory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } calcHistory.UpdateDate = DateTime.Now; db.Entry(calcHistory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CalcHistoryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }