コード例 #1
0
        private Contact CreateContact()
        {
            var identifier = CreateUniqueIdentifier();

            var contact = _contactRepository.CreateContact(ID.NewID);

            contact.Identifiers.AuthenticationLevel = AuthenticationLevel.None;
            contact.System.Classification           = 0;
            contact.ContactSaveMode               = ContactSaveMode.AlwaysSave;
            contact.Identifiers.Identifier        = identifier;
            contact.System.OverrideClassification = 0;
            contact.System.Value      = 0;
            contact.System.VisitCount = 0;

/*
 *          var contactPreferences = contact.GetFacet<IContactPreferences>("Preferences");
 *          contactPreferences.Language = _languages;
 */
            var contactPersonalInfo = contact.GetFacet <IContactPersonalInfo>("Personal");

            contactPersonalInfo.FirstName = Name.First();
            contactPersonalInfo.Surname   = Name.Last();

            var contactEmailAddresses = contact.GetFacet <IContactEmailAddresses>("Emails");

            contactEmailAddresses.Entries.Create("Work").SmtpAddress = Internet.Email($"{contactPersonalInfo.FirstName} {contactPersonalInfo.Surname}");
            contactEmailAddresses.Preferred = "Work";

            var leaseOwner = new LeaseOwner("CONTACT_CREATE", LeaseOwnerType.OutOfRequestWorker);
            var options    = new ContactSaveOptions(true, leaseOwner, null);

            _contactRepository.SaveContact(contact, options);

            return(contact);
        }
コード例 #2
0
        public Contact CreateContact()
        {
            var identifier = "XGen" + ContactCount;

            var contactRepository = new ContactRepository();

            var contact = contactRepository.LoadContactReadOnly(identifier);

            while (contact != null)
            {
                ContactCount++;
                identifier = "XGen" + ContactCount;
                contact    = contactRepository.LoadContactReadOnly(identifier);
            }

            contact = contactRepository.CreateContact(ID.NewID);
            contact.Identifiers.AuthenticationLevel = AuthenticationLevel.None;
            contact.System.Classification           = 0;
            contact.ContactSaveMode               = ContactSaveMode.AlwaysSave;
            contact.Identifiers.Identifier        = "XGen" + ContactCount;
            contact.System.OverrideClassification = 0;
            contact.System.Value      = 0;
            contact.System.VisitCount = 0;

            var contactPreferences = contact.GetFacet <IContactPreferences>("Preferences");

            contactPreferences.Language = _languages[ContactCount % _languages.Length];

            var contactPersonalInfo = contact.GetFacet <IContactPersonalInfo>("Personal");

            contactPersonalInfo.FirstName = Faker.Name.First();
            contactPersonalInfo.Surname   = Faker.Name.Last();

            var contactEmailAddresses = contact.GetFacet <IContactEmailAddresses>("Emails");

            contactEmailAddresses.Entries.Create("Work").SmtpAddress =
                Faker.Internet.Email($"{contactPersonalInfo.FirstName} {contactPersonalInfo.Surname}");
            contactEmailAddresses.Preferred = "Work";

            var leaseOwner = new LeaseOwner("CONTACT_CREATE", LeaseOwnerType.OutOfRequestWorker);
            var options    = new ContactSaveOptions(true, leaseOwner, null);

            contactRepository.SaveContact(contact, options);

            DoContactCreated(contact);
            return(contact);
        }
        public override bool SaveContact(IContact contact, ContactSaveOptions saveOptions)
        {
            var res = this.contactService.Save(
                this.modelMapper.Map<IContact, ElasticContact>(contact),
                this.modelMapper.Map<LeaseOwner, ElasticLeaseOwner>(saveOptions.LeaseOwner),
                saveOptions.Release,
                this.ctx);

            if (res && saveOptions.Release)
            {
                contact.Lease = null;
            }

            return res;
        }