public async Task <IHttpActionResult> PostTeacherBroadcast(TeacherBroadcast teacherBroadcast) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TeacherBroadcasts.Add(teacherBroadcast); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (TeacherBroadcastExists(teacherBroadcast.teacherId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = teacherBroadcast.teacherId }, teacherBroadcast)); }
public async Task <IHttpActionResult> PutTeacherBroadcast(int id, TeacherBroadcast teacherBroadcast) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != teacherBroadcast.teacherId) { return(BadRequest()); } db.Entry(teacherBroadcast).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeacherBroadcastExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetTeacherBroadcast(int id) { TeacherBroadcast teacherBroadcast = await db.TeacherBroadcasts.FindAsync(id); if (teacherBroadcast == null) { return(NotFound()); } return(Ok(teacherBroadcast)); }
public async Task <IHttpActionResult> DeleteTeacherBroadcast(int id) { TeacherBroadcast teacherBroadcast = await db.TeacherBroadcasts.FindAsync(id); if (teacherBroadcast == null) { return(NotFound()); } db.TeacherBroadcasts.Remove(teacherBroadcast); await db.SaveChangesAsync(); return(Ok(teacherBroadcast)); }