public async Task <IActionResult> PutSupportiveStaff([FromRoute] int id, [FromBody] SupportiveStaff supportiveStaff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != supportiveStaff.SupportiveStaffId) { return(BadRequest()); } _context.Entry(supportiveStaff).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupportiveStaffExists(id)) { return(NotFound()); } else { throw; } } supportiveStaff = _context.SupportiveStaffs.Include(e => e.College).FirstOrDefault(e => e.SupportiveStaffId == supportiveStaff.SupportiveStaffId); return(Ok(supportiveStaff)); }
public async Task <IActionResult> PostSupportiveStaff([FromBody] SupportiveStaff supportiveStaff) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SupportiveStaffs.Add(supportiveStaff); await _context.SaveChangesAsync(); supportiveStaff = _context.SupportiveStaffs.Include(e => e.College).FirstOrDefault(e => e.SupportiveStaffId == supportiveStaff.SupportiveStaffId); return(CreatedAtAction("GetSupportiveStaff", new { id = supportiveStaff.SupportiveStaffId }, supportiveStaff)); }