public IHttpActionResult PutPushRegistrations(int id, PushRegistrations pushRegistrations) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != pushRegistrations.Id) { return BadRequest(); } db.Entry(pushRegistrations).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PushRegistrationsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostPushRegistrations(PushRegistrations pushRegistrations) { if (!ModelState.IsValid) { return BadRequest(ModelState); } else if (db.PushRegistrations.Any(r => r.TripUserId == pushRegistrations.TripUserId && r.RegistrationId == pushRegistrations.RegistrationId)) { return null; } db.PushRegistrations.Add(pushRegistrations); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = pushRegistrations.Id }, pushRegistrations); }