public async Task <IActionResult> Put([FromBody] Student student, int id) { if (!await _context.Students.AnyAsync(c => c.Id == id)) { return(NotFound()); } _context.Entry(student).State = EntityState.Modified; _context.Students.Update(student); await _context.SaveChangesAsync(); return(Ok(student)); }
public async Task <IActionResult> Put([FromBody] Teacher teacher, int id) { if (!await _context.Teachers.AnyAsync(c => c.Id == id)) { return(NotFound()); } _context.Entry(teacher).State = EntityState.Modified; _context.Teachers.Update(teacher); await _context.SaveChangesAsync(); return(Ok(teacher)); }
public async Task <IActionResult> Put([FromBody] Course course, int id) { var entityId = await _context.Database.GetDbConnection().QueryFirstOrDefaultAsync <int>(@" SELECT CourseId from Course WHERE CourseId = @id", new { id }); if (entityId == default(int)) { return(NotFound()); } _context.Entry(course).State = EntityState.Modified; _context.Courses.Update(course); await _context.SaveChangesAsync(); return(Ok(course)); }