public IHttpActionResult PutMechanicNotification(int id, MechanicNotification mechanicNotification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mechanicNotification.Id) { return(BadRequest()); } db.Entry(mechanicNotification).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MechanicNotificationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMechanicNotification(int id) { MechanicNotification mechanicNotification = db.MechanicNotifications.Find(id); if (mechanicNotification == null) { return(NotFound()); } return(Ok(mechanicNotification)); }
public IHttpActionResult PostMechanicNotification(MechanicNotification mechanicNotification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MechanicNotifications.Add(mechanicNotification); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = mechanicNotification.Id }, mechanicNotification)); }
public IHttpActionResult DeleteMechanicNotification(int id) { MechanicNotification mechanicNotification = db.MechanicNotifications.Find(id); if (mechanicNotification == null) { return(NotFound()); } db.MechanicNotifications.Remove(mechanicNotification); db.SaveChanges(); return(Ok(mechanicNotification)); }