public async Task<IHttpActionResult> PutHit(int id, Hit hit) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != hit.Id) { return BadRequest(); } db.Entry(hit).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HitExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostHit(Hit hit) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Hits.Add(hit); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = hit.Id }, hit); }