public async Task<IHttpActionResult> PutStudentGrade(int id, StudentGrade studentGrade) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != studentGrade.StudentGradeId) { return BadRequest(); } db.Entry(studentGrade).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentGradeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostStudentGrade(StudentGrade studentGrade) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.StudentGrades.Add(studentGrade); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = studentGrade.StudentGradeId }, studentGrade); }