Commit d1a28cb5 authored by elisabeth kee's avatar elisabeth kee

mise à jour de tous les patchs

parent dd0b4e78
......@@ -71,13 +71,14 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateAge")
public Response updateAge(@PathParam("id") Long id, Profile p) {
int age = p.getAge();
public Response updateAge(@PathParam("id") Long id, String newAge) {
String newAge2 = newAge.replace('"',' ');
int newAge3 = Integer.parseInt(newAge2);
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
Profile pBDD = optional.get();
pBDD.setAge(age);
pBDD.setAge(newAge3);
profileRepository.save(pBDD);
return Response.ok(pBDD).build();
} else {
......@@ -107,13 +108,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateGender")
public Response updateGender(@PathParam("id") Long id, Profile p) {
String gender = p.getGender();
public Response updateGender(@PathParam("id") Long id, String newGender) {
String newGender2 = newGender.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
Profile pBDD = optional.get();
pBDD.setGender(gender);
pBDD.setGender(newGender2.strip());
profileRepository.save(pBDD);
return Response.ok(pBDD).build();
} else {
......@@ -125,13 +126,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updatePet")
public Response updatePet(@PathParam("id") Long id, Profile p) {
String pet = p.getPet();
public Response updatePet(@PathParam("id") Long id, String newPet) {
String newPet2 = newPet.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
Profile pBDD = optional.get();
pBDD.setPet(pet);
pBDD.setPet(newPet2.strip());
profileRepository.save(pBDD);
return Response.ok(pBDD).build();
} else {
......@@ -143,13 +144,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateContact")
public Response updateContact(@PathParam("id") Long id, Profile p) {
String partner = p.getContact();
public Response updateContact(@PathParam("id") Long id, String newContact) {
String newContact2 = newContact.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
Profile pBDD = optional.get();
pBDD.setContact(partner);
pBDD.setContact(newContact2.strip());
profileRepository.save(pBDD);
return Response.ok(pBDD).build();
} else {
......@@ -161,13 +162,12 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateLovers")
public Response updateLovers(@PathParam("id") Long id, Profile p) {
List<Lover> lovers = p.getLovers();
public Response updateLovers(@PathParam("id") Long id, List<Lover> newLovers) {
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
Profile pBDD = optional.get();
pBDD.setLovers(lovers);
pBDD.setLovers(newLovers);
profileRepository.save(pBDD);
return Response.ok(pBDD).build();
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment