public IHttpActionResult AddUpdateEmails(List <ContactEmailModel> contactEmails)
        {
            long contactID = 0;

            if (contactEmails.Count > 0)
            {
                contactID = contactEmails[0].ContactID;
            }
            return(new HttpResult <Response <ContactEmailModel> >(_emailDataProvider.UpdateEmails(contactID, contactEmails), Request));
        }
Example #2
0
        /// <summary>
        /// Perform Address,Phone,Email Add update operations
        /// </summary>
        /// <param name="contact"></param>
        /// <param name="spResults"></param>
        /// <returns></returns>
        public virtual bool ContactOtherOperations(Model contact, Response <Model> spResults)
        {
            Response <ContactAddressModel> addressResults = null;

            if (contact.CopyContactAddress)
            {
                var address = contact.Addresses.Select(a => { a.AddressID = null; return(a); });
                addressResults = addressDataProvider.CopyContactAddresses(spResults.ID, address.ToList());
            }
            else
            {
                addressResults = addressDataProvider.UpdateAddresses(spResults.ID, contact.Addresses);
            }
            if (addressResults.ResultCode != 0)
            {
                spResults.ResultCode    = addressResults.ResultCode;
                spResults.ResultMessage = addressResults.ResultMessage;
                return(false);
            }

            var emailResults = emailDataProvider.UpdateEmails(spResults.ID, contact.Emails);

            if (emailResults.ResultCode != 0)
            {
                spResults.ResultCode    = emailResults.ResultCode;
                spResults.ResultMessage = emailResults.ResultMessage;
                return(false);
            }

            var phoneResults = phoneDataProvider.UpdatePhones(spResults.ID, contact.Phones);

            if (phoneResults.ResultCode != 0)
            {
                spResults.ResultCode    = phoneResults.ResultCode;
                spResults.ResultMessage = phoneResults.ResultMessage;
                return(false);
            }

            var clientIdentifierResults = clientIdentifierDataProvider.AddUpdateContactClientIdentifiers(spResults.ID, contact.ClientAlternateIDs);

            if (clientIdentifierResults.ResultCode != 0)
            {
                spResults.ResultCode    = clientIdentifierResults.ResultCode;
                spResults.ResultMessage = clientIdentifierResults.ResultMessage;
                return(false);
            }

            return(true);
        }