public async Task <IActionResult> PutSubject([FromRoute] int id, [FromBody] Subject subject) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != subject.Subj_Id) { return(BadRequest()); } _context.Entry(subject).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutInstructor([FromRoute] int id, [FromBody] Instructor instructor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != instructor.Id) { return(BadRequest()); } _context.Entry(instructor.User).State = EntityState.Modified; _context.Entry(instructor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstructorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }