// PUT odata/Reports(5) public async Task<IHttpActionResult> Put([FromODataUri] int key, Report report) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != report.ReportId) { return BadRequest(); } db.Entry(report).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReportExists(key)) { return NotFound(); } else { throw; } } return Updated(report); }
// POST odata/Reports public async Task<IHttpActionResult> Post(Report report) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Reports.Add(report); await db.SaveChangesAsync(); return Created(report); }