public PersonnalPartyModel(LoanApplicationRole role) { this.IsNew = false; this.PartyRoleId = role.PartyRoleId; this.LoanApplicationRoleId = role.Id; PartyRole partyRole = role.PartyRole; Party party = partyRole.Party; this.PartyId = party.Id; Person personAsCustomer = party.Person; Customer customer = partyRole.Customer; if (party.PartyType.Id == PartyType.PersonType.Id) { this.Name = StringConcatUtility.Build(" ", personAsCustomer.LastNameString + "," , personAsCustomer.FirstNameString, personAsCustomer.MiddleInitialString, personAsCustomer.NameSuffixString); } else { Organization employerOrg = party.Organization; this.Name = employerOrg.OrganizationName; } Address postalAddress = party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == AddressType.PostalAddressType.Id && entity.PostalAddress.PostalAddressTypeId == PostalAddressType.HomeAddressType.Id && entity.PostalAddress.IsPrimary); if (postalAddress != null && postalAddress.PostalAddress != null) { PostalAddress postalAddressSpecific = postalAddress.PostalAddress; this.Address = StringConcatUtility.Build(", ", postalAddressSpecific.StreetAddress, postalAddressSpecific.Barangay, postalAddressSpecific.Municipality, postalAddressSpecific.City, postalAddressSpecific.Province, postalAddressSpecific.State, postalAddressSpecific.Country.Name, postalAddressSpecific.PostalCode); } }
public static PartyRole CreateLoanApplicationRole(LoanApplication loanApplication, RoleType roletype, Party party, DateTime today) { PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.RoleTypeId = roletype.Id; partyRole.EffectiveDate = today; partyRole.EndDate = null; LoanApplicationRole loanApplicationRole = new LoanApplicationRole(); loanApplicationRole.LoanApplication = loanApplication; loanApplicationRole.PartyRole = partyRole; Context.LoanApplicationRoles.AddObject(loanApplicationRole); return partyRole; }