public IHttpActionResult PutGradlesSubjects(decimal id, GradlesSubjects gradlesSubjects) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gradlesSubjects.student_ID) { return(BadRequest()); } db.Entry(gradlesSubjects).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GradlesSubjectsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostGradlesSubjects(GradlesSubjects gradlesSubjects) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GradlesSubjects.Add(gradlesSubjects); try { db.SaveChanges(); } catch (DbUpdateException) { if (GradlesSubjectsExists(gradlesSubjects.student_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = gradlesSubjects.student_ID }, gradlesSubjects)); }
public IHttpActionResult DeleteGradlesSubjects(decimal id) { GradlesSubjects gradlesSubjects = db.GradlesSubjects.Find(id); if (gradlesSubjects == null) { return(NotFound()); } db.GradlesSubjects.Remove(gradlesSubjects); db.SaveChanges(); return(Ok(gradlesSubjects)); }