Skip to content

Commit

Permalink
Another bugfix for update method of the pet entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
FruTooTi committed Dec 31, 2023
1 parent e13085c commit 3dacd35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public PetMapper(ModelMapper modelMapper) {
mapper -> {
mapper.skip(src -> src.getPetOwnerID(),
(dest, val) -> dest.getPetOwnerID().setPetOwnerID((Integer) val));
mapper.skip(src -> src.getPetTypeID(),
(dest, val) -> dest.getPetTypeID().setPetTypeID((Integer) val));
mapper.skip(src -> src.getPetTypeID(),
(dest, val) -> dest.getPetTypeID().setType((String) val));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.production.ehayvanbackendapi.DTO.CustomerDTO;
import com.production.ehayvanbackendapi.DTO.ScheduleDTO;
import com.production.ehayvanbackendapi.DTO.request.CreateOrUpdateScheduleDTO;
import com.production.ehayvanbackendapi.Entities.Customer;
import com.production.ehayvanbackendapi.Entities.Schedule;
import org.modelmapper.ModelMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public PetDTO postPet(CreateOrUpdatePetDTO newPetDto){
ownerOfPet.setPetOwnerID(newPetDto.getPetOwnerID());
newPet.setPetOwnerID(ownerOfPet);

// Set the petType of newly created pet.
PetType petType = new PetType();
petType.setPetTypeID(newPetDto.getPetTypeID());
newPet.setPetTypeID(petType);

try{
petRepository.save(newPet);
return petMapper.convertToDto(newPet);
Expand Down

0 comments on commit 3dacd35

Please sign in to comment.