/// <summary> /// Return list of all donors whose codes are /// in our file list. /// </summary> /// <returns></returns> public List <Donor> DonorsInFileList() { List <Donor> retList = new List <Donor>(); // For each file, if it's of the proper type, // (ie if it's not a type for which donor // is irrelevant), add its donor to our // return list. List <string> codes = new List <string>(); foreach (HllFileInfo hfi in RegularHllFiles) { if (hfi.HasDonor) { codes.Add(hfi.DonorCode); } } // remove dupes: codes = codes.Distinct().ToList(); // Now add donors to our retList, using the codes we found: foreach (string c in codes) { Donor d = context.FindDonorByCode(c); if (d == null) // Uh-oh! This is a new donor. { // add it to datastore as well as to our return list d = new Donor(c, c); context.AddOrUpdateDonor(d); } retList.Add(d); } // Sort the list by donor name: return(retList.OrderBy(d => d.name).Distinct().ToList()); }