public async Task <IActionResult> PutTeacher([FromRoute] int id, [FromBody] Teacher teacher) { if (id != teacher.Id) { return(BadRequest()); } _context.Entry(teacher).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetTeacher", new { id = teacher.Id }, teacher)); } catch (DbUpdateConcurrencyException) { if (!TeacherExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCourse([FromRoute] int id, [FromBody] Course course) { if (id != course.Id) { return(BadRequest()); } _context.Entry(course).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetCourse", new { id = course.Id }, course)); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStudent([FromRoute] int id, [FromBody] Student student) { if (id != student.Id) { return(BadRequest()); } _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudent", new { id = student.Id }, student)); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }