Skip to content

Commit

Permalink
Add friend after apointement
Browse files Browse the repository at this point in the history
  • Loading branch information
YassineBOUJNAH committed Jun 3, 2020
1 parent b069b6d commit 0616914
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import com.ensias.healthcareapp.R;
import com.ensias.healthcareapp.model.ApointementInformation;
import com.ensias.healthcareapp.model.Doctor;
import com.ensias.healthcareapp.model.Patient;
import com.firebase.ui.firestore.FirestoreRecyclerAdapter;
import com.firebase.ui.firestore.FirestoreRecyclerOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -46,6 +49,26 @@ public void onClick(View v) {
FirebaseFirestore.getInstance().collection("Doctor").document(apointementInformation.getDoctorId()).collection("calendar")
.document(apointementInformation.getTime().replace("/","_")).set(apointementInformation);

//////////// here add patient friend to doctor

FirebaseFirestore.getInstance().document("Patient/"+apointementInformation.getPatientId()).get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
FirebaseFirestore.getInstance().collection("Doctor").document(apointementInformation.getDoctorId()+"")
.collection("MyPatients").document(apointementInformation.getPatientId()).set(documentSnapshot.toObject(Patient.class));
}
});
FirebaseFirestore.getInstance().document("Doctor/"+apointementInformation.getDoctorId()).get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
FirebaseFirestore.getInstance().collection("Patient").document(apointementInformation.getPatientId()+"")
.collection("MyDoctors").document(apointementInformation.getPatientId()).set(documentSnapshot.toObject(Doctor.class));
}
});


getSnapshots().getSnapshot(position).getReference().delete();
}
});
Expand Down

0 comments on commit 0616914

Please sign in to comment.