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 { ...@@ -71,13 +71,14 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateAge") @Path("{id}/updateAge")
public Response updateAge(@PathParam("id") Long id, Profile p) { public Response updateAge(@PathParam("id") Long id, String newAge) {
int age = p.getAge(); String newAge2 = newAge.replace('"',' ');
int newAge3 = Integer.parseInt(newAge2);
Optional<Profile> optional = profileRepository.findById(id); Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
Profile pBDD = optional.get(); Profile pBDD = optional.get();
pBDD.setAge(age); pBDD.setAge(newAge3);
profileRepository.save(pBDD); profileRepository.save(pBDD);
return Response.ok(pBDD).build(); return Response.ok(pBDD).build();
} else { } else {
...@@ -107,13 +108,13 @@ public class ProfileResource { ...@@ -107,13 +108,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateGender") @Path("{id}/updateGender")
public Response updateGender(@PathParam("id") Long id, Profile p) { public Response updateGender(@PathParam("id") Long id, String newGender) {
String gender = p.getGender(); String newGender2 = newGender.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id); Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
Profile pBDD = optional.get(); Profile pBDD = optional.get();
pBDD.setGender(gender); pBDD.setGender(newGender2.strip());
profileRepository.save(pBDD); profileRepository.save(pBDD);
return Response.ok(pBDD).build(); return Response.ok(pBDD).build();
} else { } else {
...@@ -125,13 +126,13 @@ public class ProfileResource { ...@@ -125,13 +126,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updatePet") @Path("{id}/updatePet")
public Response updatePet(@PathParam("id") Long id, Profile p) { public Response updatePet(@PathParam("id") Long id, String newPet) {
String pet = p.getPet(); String newPet2 = newPet.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id); Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
Profile pBDD = optional.get(); Profile pBDD = optional.get();
pBDD.setPet(pet); pBDD.setPet(newPet2.strip());
profileRepository.save(pBDD); profileRepository.save(pBDD);
return Response.ok(pBDD).build(); return Response.ok(pBDD).build();
} else { } else {
...@@ -143,13 +144,13 @@ public class ProfileResource { ...@@ -143,13 +144,13 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateContact") @Path("{id}/updateContact")
public Response updateContact(@PathParam("id") Long id, Profile p) { public Response updateContact(@PathParam("id") Long id, String newContact) {
String partner = p.getContact(); String newContact2 = newContact.replace('"',' ');
Optional<Profile> optional = profileRepository.findById(id); Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
Profile pBDD = optional.get(); Profile pBDD = optional.get();
pBDD.setContact(partner); pBDD.setContact(newContact2.strip());
profileRepository.save(pBDD); profileRepository.save(pBDD);
return Response.ok(pBDD).build(); return Response.ok(pBDD).build();
} else { } else {
...@@ -161,13 +162,12 @@ public class ProfileResource { ...@@ -161,13 +162,12 @@ public class ProfileResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("{id}/updateLovers") @Path("{id}/updateLovers")
public Response updateLovers(@PathParam("id") Long id, Profile p) { public Response updateLovers(@PathParam("id") Long id, List<Lover> newLovers) {
List<Lover> lovers = p.getLovers();
Optional<Profile> optional = profileRepository.findById(id); Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) { if (optional.isPresent()) {
Profile pBDD = optional.get(); Profile pBDD = optional.get();
pBDD.setLovers(lovers); pBDD.setLovers(newLovers);
profileRepository.save(pBDD); profileRepository.save(pBDD);
return Response.ok(pBDD).build(); return Response.ok(pBDD).build();
} else { } 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