public IHttpActionResult PutNotification(int id, Notification notification) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != notification.Id) { return BadRequest(); } db.Entry(notification).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NotificationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostNotification(Notification notification) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Notifications.Add(notification); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = notification.Id }, notification); }