protected override TTargetType Mapping(TSourceType source, TTargetType target) { if (Exchanger.SourceRepository.Client == null) { var client = new Contact { Email = "*****@*****.**" }; Exchanger.SourceRepository.ClientContactId = client.Id; if (Exchanger.SourceRepository.Contacts == null) { Exchanger.SourceRepository.Contacts = new List <Contact>(); } Exchanger.SourceRepository.Contacts.Add(client); } //set CreatedBy to Client // ReSharper disable once PossibleNullReferenceException var cKey = Exchanger.SourceRepository.Client.Id.ToString(); var cMapping = Exchanger.GetOrCreateMappings <MappingContactToContact>(); var tContact = cMapping.GetOrCreateTargetObject(cKey); target.CreatedBy = new ContactKey { Email = tContact.Email }; //set CreatedOn target.CreatedOn = Exchanger.SourceRepository.CreatedOn; return(target); }
/// <summary> /// Populate a provided Resource project /// </summary> /// <param name="resource">Resource object to populate with contact details</param> /// <param name="contact">dPOW contact object containing the details</param> private static void PopulateResourceFromContact(Resource resource, Contact contact) { // Assign resource contact name and email address // If contact does not have a GivenName (appears to often be the case), fall back on the CompanyName // MS Project reports errors if the name contains a '[' or ']', which are found in the '[Not Assigned]' contact, so replace these with normal brackets resource.Name = (contact.GivenName ?? contact.CompanyName).Replace("[", "(").Replace("]", ")"); resource.EmailAddress = contact.Email; }