Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        public async Task <IHttpActionResult> GetTeacherBroadcast(int id)
        {
            TeacherBroadcast teacherBroadcast = await db.TeacherBroadcasts.FindAsync(id);

            if (teacherBroadcast == null)
            {
                return(NotFound());
            }

            return(Ok(teacherBroadcast));
        }
Exemple #4
0
        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));
        }