/// <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()); }
protected override object ObjectFromVestaRow(DBWrapper context, ExcelRow row, int year) { object retObj = null; string donor_name; GiftLabelInfo workObj = new GiftLabelInfo(); workObj.year = year; // If there's anything in the spreadsheet's "Donor ID" // column, use that to identify this row's donor. // Otherwise, use the "Donor Name" column. donor_name = row[this.field_indices["Donor Name"]]; // We know the donor name, but not code. If there's already // a Donor with this name, we're set -- just use that Donor // along with whatever code it has. Otherwise, make a Donor // from the name and add that to the database. Donor d = context.FindDonorByName(donor_name); if (d == null) { d = new Donor(donor_name); context.AddOrUpdateDonor(d); } workObj.donor_code = d.code; workObj.donor_name = d.name; int child_age; bool parsed_ok = int.TryParse(row[this.field_indices["Age"]], out child_age); if (!parsed_ok) { child_age = -1; } workObj.child_age = child_age; string scratch = (row[this.field_indices["Gender"]]).Substring(0, 1).ToUpper(); if (scratch != "M" && scratch != "F") { scratch = "NotSpecified"; } workObj.child_gender = scratch; workObj.child_name = row[this.field_indices["Family Member First Name"]]; workObj.family_id = row[this.field_indices["Family ID"]]; workObj.family_name = row[this.field_indices["Family Name"]]; workObj.request_detail = row[this.field_indices["Request Detail"]]; workObj.request_type = row[this.field_indices["Request Type"]]; retObj = workObj; return(retObj); }
protected override object ObjectFromVestaRow(DBWrapper context, ExcelRow row, int year) { string donor_name; BagLabelInfo workObj = new BagLabelInfo(); workObj.year = year; donor_name = row[this.field_indices["Donor Name"]]; Donor d = context.FindDonorByName(donor_name); if (d == null) { d = new Donor(donor_name); context.AddOrUpdateDonor(d); } workObj.donor_code = d.code; workObj.donor_name = d.name; workObj.family_id = row[this.field_indices["Family ID"]]; workObj.family_name = row[this.field_indices["Family Name"]]; workObj.family_members = row[this.field_indices["Family Members"]]; // next line is probably redundant -- we got request type in constructor: workObj.request_type = row[this.field_indices["Request Type"]]; return(workObj); }