public String addContact() { FacesContext context = FacesContext.getCurrentInstance(); Address adr = new Address(street, city, zip, country); Contact c = new Contact(firstName, lastName, email, adr); GroupDAO groupDAO = new GroupDAO(); Group g = (Group) groupDAO.getGroupById(Integer.parseInt(this.getGroupId())); c.getBooks().add(g); Entreprise e = null; if (homePhone.compareTo("") != 0) { PhoneNumber p = new PhoneNumber("HomePhone", homePhone); c.getProfiles().add(p); } if (mobilePhone.compareTo("") != 0) { PhoneNumber p = new PhoneNumber("MobilePhone", mobilePhone); c.getProfiles().add(p); } if (siret.compareTo("") != 0) { e = new Entreprise(c); e.setNumSiret(Integer.parseInt(siret)); } if (e != null) { for (PhoneNumber p : e.getProfiles()) { p.setContact(e); } ContactService.getContactService().addNewContact(e); } else { for (PhoneNumber p : c.getProfiles()) { p.setContact(c); } ContactService.getContactService().addNewContact(c); } return (e == null ? "addContactSuccess" : "addEntrepriseSuccess"); }
public Contact getContactById(String contactId) { return ContactService.getContactService().getContactById(Integer.parseInt(contactId)); }
public String deleteContact(Contact contact) { ContactService.getContactService().deleteContact(contact); return ("deleteContactSuccess"); }
public List<Contact> getListContact() { System.out.println("Liste contact recupéré via le formulaire"); List<Contact> tmp = ContactService.getContactService().getListContact(); return tmp; }