private IEnumerable <Notification> GetReferralNotifications(int doctorId) { var notifications = new List <Notification>(); IEnumerable <Referral> referrals = _referralRepository.GetReferralsForReferredDoctor(doctorId); foreach (Referral referral in referrals) { if (referral.SeenByReferredDoctor) { continue; } Patient referralPatient = _patientRepository.GetPatient(referral.PatientId); Doctor referringDoctor = _doctorRepository.GetDoctor(referral.ReferringDoctorId); string message = "Patient " + referralPatient.FirstName + " " + referralPatient.LastName + " has been referred to you by Dr. " + referringDoctor.LastName + "."; notifications.Add(new Notification { NotificationId = referral.ReferralId, Type = NotificationType.Referral, Message = message, PatientId = referral.PatientId }); } return(notifications); }