// ServicesHouseholdEnrollment methods /////////////////////////////////////// public ServicesHouseholdEnrollment MatchingEnrollment(ServicesHouseholdEnrollment enr) { return this._henrcoll.Find(e => e.year == enr.year && e.service_type == enr.service_type && e.head_of_household == enr.head_of_household ).FirstOrDefault(); }
/// <summary> /// "Type" the contents of this record into a NovaCode Cell. /// </summary> /// <param name="c"></param> /// <param name="rec"></param> protected override void TypeOneRecord(Cell c, object rec) { c.MarginTop = (int)(0.1 * (int)DocPartUnits.Margins); ServicesHouseholdEnrollment e = (ServicesHouseholdEnrollment)rec; Paragraph p = c.Paragraphs.First(); // Xceed.Words.NET should initialize Cells with one // paragraph. But, in the unlikeley case // that that paragraph isn't there, add one. if (p == null) { p = c.InsertParagraph(); } string zip = Utils.TextUtils.CanonicalPostalCode(e.postal_code); p.Append(e.head_of_household).Bold() .AppendLine(e.address) .AppendLine(e.city + ", " + e.state_or_province + " " + zip); }
/// <summary> /// Add passed-in object to database collection, if /// it's not already present. If it is already there, /// update the database element with the properties /// of the passed-inobject. /// </summary> /// <param name="bli"></param> /// <returns></returns> public ServicesHouseholdEnrollment AddOrUpdateHoEnr(ServicesHouseholdEnrollment enr) { ServicesHouseholdEnrollment dbo = this.MatchingEnrollment(enr); if (dbo == null) { // not found -- insert the one passed // to us. As a side effect, the Insert() // method updates the Id property of the // inserted object. this._henrcoll.Insert(enr); } else { // found -- set the id of the passed-in object to // that of the found object. enr.Id = dbo.Id; // Now replace the object in the database with // the one passed in. this._henrcoll.Update(enr); } return enr; }