partial void PrintDocLetter1_CanExecute(ref bool result)
{
if (this.PatientsMasterItem.DoctorsMasterItem != null)
{
var Doctor = PatientsMasterItem.DoctorsMasterItem;
var PatientList = Doctor.PatientsMasterItem;
var Letters = PatientsMasterItem.LettersSentItem;
if ((PatientList.Count() > 1) && (Letters.Any(i => i.LetterType == "DoctorLetter1")))
{
result = false;
}
else
{
result = true;
}
}
}
I think something is wrong with my second condition. I’m trying to find two things.
1) Doctors with more than 1 patient.
2) Among those patients whether a lettertype called “DoctorLetter1” has been sent or not.
The above code is working good for that particular record but not working other patients with same doctors where patient1 has already been sent with DoctorLetter1.
in this condition
updated (as per your ER diagram)
you didn’t check all Patients ‘s Letter. try..
*logic
Doctor has many patients and each patient has many letters.
if any patient (only one of them) has at least one “DoctorLetter1” sent then condition is true and result = false