src/main/java/seedu/planner/model/ModelManager.java
private void redoContactMapping(Contact contact) {
        if (contact.getAddress().isPresent()) {
            Name name = contact.getName();
            Address address = contact.getAddress().get();
            Activity activityToMap = this.activities.getActivity(name, address).orElse(null);
            Accommodation accommodationToMap = this.accommodations.getAccommodation(name, address).orElse(null);

            if (activityToMap != null) {
                Activity newActivity = new Activity(activityToMap.getName(), activityToMap.getAddress(), contact,
                        activityToMap.getCost().orElse(null), activityToMap.getTags(), activityToMap.getDuration(),
                        activityToMap.getPriority());
                this.activities.setActivity(activityToMap, newActivity);
                contactActivityMap.put(contact, newActivity);
            }
            if (accommodationToMap != null) {
                Accommodation newAccommodation = new Accommodation(accommodationToMap.getName(),
                        accommodationToMap.getAddress(), contact, activityToMap.getTags());
                this.accommodations.setAccommodation(accommodationToMap, newAccommodation);
                contactAccommodationMap.put(contact, newAccommodation);
            }
        }
    }
/**
     * A method to map a new contact to existing Activity or Accommodation if they share the same name and address
     * fields.
     */
A method to map a new contact to existing Activity or Accommodation if they share the same name and address
fields.
A method to map a new contact to existing Activity or Accommodation if they share the same name and address fields .
private void redoContactMapping(Contact contact) {
        if (contact.getAddress().isPresent()) {
            Name name = contact.getName();
            Address address = contact.getAddress().get();
            Activity activityToMap = this.activities.getActivity(name, address).orElse(null);
            Accommodation accommodationToMap = this.accommodations.getAccommodation(name, address).orElse(null);
            if (activityToMap != null) {
                Activity newActivity = new Activity(activityToMap.getName(), activityToMap.getAddress(), contact,
                        activityToMap.getCost().orElse(null), activityToMap.getTags(), activityToMap.getDuration(),
                        activityToMap.getPriority());
                this.activities.setActivity(activityToMap, newActivity);
                contactActivityMap.put(contact, newActivity);
            }
            if (accommodationToMap != null) {
                Accommodation newAccommodation = new Accommodation(accommodationToMap.getName(),
                        accommodationToMap.getAddress(), contact, activityToMap.getTags());
                this.accommodations.setAccommodation(accommodationToMap, newAccommodation);
                contactAccommodationMap.put(contact, newAccommodation);
            }
        }
    }
private void redoContactMapping ( Contact contact ) { if ( contact . getAddress ( ) . isPresent ( ) ) { Name name = contact . getName ( ) ; Address address = contact . getAddress ( ) . get ( ) ; Activity activityToMap = this . activities . getActivity ( name , address ) . orElse ( null ) ; Accommodation accommodationToMap = this . accommodations . getAccommodation ( name , address ) . orElse ( null ) ; if ( activityToMap != null ) { Activity newActivity = new Activity ( activityToMap . getName ( ) , activityToMap . getAddress ( ) , contact , activityToMap . getCost ( ) . orElse ( null ) , activityToMap . getTags ( ) , activityToMap . getDuration ( ) , activityToMap . getPriority ( ) ) ; this . activities . setActivity ( activityToMap , newActivity ) ; contactActivityMap . put ( contact , newActivity ) ; } if ( accommodationToMap != null ) { Accommodation newAccommodation = new Accommodation ( accommodationToMap . getName ( ) , accommodationToMap . getAddress ( ) , contact , activityToMap . getTags ( ) ) ; this . accommodations . setAccommodation ( accommodationToMap , newAccommodation ) ; contactAccommodationMap . put ( contact , newAccommodation ) ; } } }
A method to map a new contact to existing Activity or Accommodation if they share the same name and address
 fields.
A method to map a new contact to existing Activity or Accommodation if they share the same name and address fields .