public async Task<IHttpActionResult> PutRegistration(int id, Registration registration) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != registration.Id) { return BadRequest(); } db.Entry(registration).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegistrationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostRegistration(Registration registration) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Registrations.Add(registration); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = registration.Id }, registration); }