public async Task <IActionResult> PutAddress(int id, Address address) { var updateAddress = await _context.Address.FirstOrDefaultAsync(s => s.id == address.id); _context.Entry(updateAddress).State = EntityState.Modified; updateAddress.streetNumber = address.streetNumber; updateAddress.street = address.street; updateAddress.suburb = address.suburb; updateAddress.city = address.city; updateAddress.country = address.country; updateAddress.postCode = address.postCode; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStudent(int id, Student student) { if (id != student.studentID) { return(BadRequest()); } if (!StudentExists(id)) { return(BadRequest()); } var updateStudent = await _context.Student.FirstOrDefaultAsync(s => s.studentID == student.studentID); _context.Entry(updateStudent).State = EntityState.Modified; updateStudent.firstName = student.firstName; updateStudent.lastName = student.lastName; updateStudent.emailAddress = student.emailAddress; updateStudent.phoneNumber = student.phoneNumber; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }