Beispiel #1
0
        private Contact DoCreate(AdditionalPointOfContact pointOfContact)
        {
            var validationEntity = GetAdditionalPointOfContactValidationEntity(pointOfContact);

            pointOfContactValidator.ValidateCreate(validationEntity);

            var contact = new Contact();

            Contract.Assert(!String.IsNullOrWhiteSpace(pointOfContact.FullName), "The point of contact must have a full name value.");
            contact.FullName = pointOfContact.FullName.Trim();
            if (!string.IsNullOrWhiteSpace(pointOfContact.Position))
            {
                contact.Position = pointOfContact.Position.Trim();
            }

            foreach (var email in pointOfContact.EmailAddresses.Where(x => !String.IsNullOrWhiteSpace(x.Address)))
            {
                var newEmail = new EmailAddress
                {
                    EmailAddressTypeId = email.EmailAddressTypeId,
                    Address            = email.Address.Trim(),
                    IsPrimary          = email.IsPrimary
                };
                pointOfContact.Audit.SetHistory(newEmail);
                contact.EmailAddresses.Add(newEmail);
                Context.EmailAddresses.Add(newEmail);
            }
            foreach (var phoneNumber in pointOfContact.PhoneNumbers.Where(x => !String.IsNullOrWhiteSpace(x.Number)))
            {
                var newPhoneNumber = new PhoneNumber
                {
                    Number            = phoneNumber.Number.Trim(),
                    Extension         = phoneNumber.Extension.Trim(),
                    PhoneNumberTypeId = phoneNumber.PhoneNumberTypeId,
                    IsPrimary         = phoneNumber.IsPrimary
                };
                pointOfContact.Audit.SetHistory(newPhoneNumber);
                contact.PhoneNumbers.Add(newPhoneNumber);
                Context.PhoneNumbers.Add(newPhoneNumber);
            }

            pointOfContact.Audit.SetHistory(contact);
            this.Context.Contacts.Add(contact);
            return(contact);
        }
Beispiel #2
0
        private AdditionalPointOfContactValidationEntity GetAdditionalPointOfContactValidationEntity(AdditionalPointOfContact pointOfContact)
        {
            var numberOfPrimaryEmailAddresses = pointOfContact.EmailAddresses.Where(x => x.IsPrimary).Count();
            var numberOfPrimaryPhoneNumbers   = pointOfContact.PhoneNumbers.Where(x => x.IsPrimary).Count();

            return(new AdditionalPointOfContactValidationEntity(
                       fullName: pointOfContact.FullName,
                       position: pointOfContact.Position,
                       numberOfPrimaryEmailAddresses: numberOfPrimaryEmailAddresses,
                       numberOfPrimaryPhoneNumbers: numberOfPrimaryPhoneNumbers));
        }
Beispiel #3
0
 /// <summary>
 /// Adds a new point of the contact to the datastore.
 /// </summary>
 /// <param name="pointOfContact">The point of contact.</param>
 /// <returns>The Contact that was added to the context.</returns>
 public async Task <Contact> CreateAsync(AdditionalPointOfContact pointOfContact)
 {
     return(DoCreate(pointOfContact));
 }
Beispiel #4
0
 /// <summary>
 /// Adds a new point of the contact to the datastore.
 /// </summary>
 /// <param name="pointOfContact">The point of contact.</param>
 /// <returns>The Contact that was added to the context.</returns>
 public Contact Create(AdditionalPointOfContact pointOfContact)
 {
     return(DoCreate(pointOfContact));
 }
Beispiel #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pointOfContact"></param>
 /// <returns></returns>
 public Task <Contact> CreateAsync(AdditionalPointOfContact pointOfContact)
 {
     Contract.Requires(pointOfContact != null, "The point of contact must not be null.");
     return(Task.FromResult <Contact>(null));
 }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pointOfContact"></param>
 /// <returns></returns>
 public Contact Create(AdditionalPointOfContact pointOfContact)
 {
     Contract.Requires(pointOfContact != null, "The point of contact must not be null.");
     return(null);
 }