Ignore:
Timestamp:
03/09/23 16:11:48 (16 months ago)
Author:
GitHub <noreply@…>
Branches:
main
Children:
0078d84, 4ab3aae
Parents:
8b7dd7f (diff), 264d675 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
SazdovaEkaterina <74919977+SazdovaEkaterina@…> (03/09/23 16:11:48)
git-committer:
GitHub <noreply@…> (03/09/23 16:11:48)
Message:

Merge pull request #9 from SazdovaEkaterina/fix-foreign-keys

Fix Database Mapping in Models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java

    r8b7dd7f rc3278ac  
    11package finki.paw5.web.controllers;
    22
     3import finki.paw5.model.entities.Adopter;
    34import finki.paw5.model.entities.Adoption;
    45import finki.paw5.model.entities.Pet;
    5 import finki.paw5.model.entities.User;
    6 import finki.paw5.model.exceptions.InvalidPetIdException;
    76import finki.paw5.service.AdoptionService;
    87import finki.paw5.service.PetService;
     
    2524    }
    2625
    27     @PostMapping("/submit-adopton-{id}")
     26    @PostMapping("/submit-adoption-{id}")
    2827    public String saveAdoption(@PathVariable Integer id, HttpServletRequest request) {
    2928
    3029        Pet pet = this.petService.findById(id);
    3130       
    32         User user = (User) request.getSession().getAttribute("user");
     31        Adopter adopter = (Adopter) request.getSession().getAttribute("user");
    3332
    34         Adoption adoption = new Adoption(LocalDate.now(), null, false, user.getId());
     33        Adoption adoption = new Adoption(LocalDate.now(), null, false, adopter);
    3534        this.adoptionService.save(adoption);
    3635
    37         pet.setAdoptionId(adoption.getId());
     36        pet.setAdoption(adoption);
    3837        this.petService.save(pet);
    3938
Note: See TracChangeset for help on using the changeset viewer.