@Service
public class ContractService {
@Autowired
private ContractRepository contractRepository;
@Transactional
public Contract updateContract(Long id, Contract newContractDetails) {
return contractRepository.findById(id).map(contract -> {
contract.setName(newContractDetails.getName());
contract.setStartDate(newContractDetails.getStartDate());
contract.setEndDate(newContractDetails.getEndDate());
return contractRepository.save(contract);
}).orElseGet(() -> {
newContractDetails.setId(id);
return contractRepository.save(newContractDetails);
});
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: