public static Contact_V01 SaveContact(Contact_V01 contact, string distributorID)
        {
            ExpireAllContacts(distributorID);

            var request = new SaveContactRequest_V01
            {
                Contact       = contact,
                DistributorID = distributorID,
                IsImport      = false
            };

            using (var proxy = ServiceClientProvider.GetDistributorCRMServiceProxy())
            {
                try
                {
                    var response = proxy.SaveContact(new SaveContactRequest1(request)).SaveContactResult as SaveContactResponse_V01;
                    if (response != null && response.Status == ServiceResponseStatusType.Success)
                    {
                        return(response.Contact as Contact_V01);
                    }

                    return(null);
                }
                catch (Exception ex)
                {
                    Log(ex, proxy);
                    return(null);
                }
            }
        }
        private InvoiceSearchFilter CreateContactSearchFilter(Contact_V01 invoiceContact)
        {
            var searchFilter = new InvoiceSearchFilter();

            try
            {
                if (null != invoiceContact)
                {
                    searchFilter.SearchByDateOrAmount = false;
                    if (null != invoiceContact.EnglishName)
                    {
                        if (!string.IsNullOrEmpty(invoiceContact.EnglishName.First))
                        {
                            searchFilter.FirstName = invoiceContact.EnglishName.First;
                        }

                        if (!string.IsNullOrEmpty(invoiceContact.EnglishName.Last))
                        {
                            searchFilter.LastName = invoiceContact.EnglishName.Last;
                        }
                    }

                    if (null != invoiceContact.PrimaryAddress)
                    {
                        if (!string.IsNullOrEmpty(invoiceContact.PrimaryAddress.Line1))
                        {
                            searchFilter.StreetAddress = invoiceContact.PrimaryAddress.Line1;
                        }
                        if (!string.IsNullOrEmpty(invoiceContact.PrimaryAddress.City))
                        {
                            searchFilter.City = invoiceContact.PrimaryAddress.City;
                        }
                        if (!string.IsNullOrEmpty(invoiceContact.PrimaryAddress.StateProvinceTerritory))
                        {
                            searchFilter.State = invoiceContact.PrimaryAddress.StateProvinceTerritory;
                        }
                        if (!string.IsNullOrEmpty(invoiceContact.PrimaryAddress.PostalCode))
                        {
                            searchFilter.ZipCode = invoiceContact.PrimaryAddress.PostalCode;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyHLWebUtil.LogExceptionWithContext(ex);
            }
            return(searchFilter);
        }
 public void OnContactDetailsLoaded(Contact_V01 contactWithDetails, List <int> assignedLists)
 {
 }
        /// <summary>
        ///     Save contact confirmation email
        /// </summary>
        /// <param name="contact">Contact saved</param>
        /// <param name="distributorId">Name of the owner of the site</param>
        /// ///
        /// <param name="extension">Website extension</param>
        /// ///
        /// <param name="locale">Customer locale</param>
        /// ///
        /// <param name="domain">Domain for this locale</param>
        /// ///
        /// <param name="primaryLocale"></param>
        /// <param name="registrationSource">Where did the customer got the invitation</param>
        /// <param name="distributorName"></param>
        /// <param name="distributorEmail"></param>
        /// <param name="isDistributorCopied"></param>
        /// <returns>True if success</returns>
        public static bool SendContactConfirmationEmail(
            Contact_V01 contact,
            string distributorId,
            string extension,
            string locale,
            string domain,
            String distributorName,
            String distributorEmail,
            Boolean isDistributorCopied,
            String primaryLocale,
            RegistrationSource registrationSource = RegistrationSource.Other
            )
        {
            if (contact.EmailAddresses.Count < 1)
            {
                throw new ArgumentException("Argument can not be null", "Contact Email");
            }

            if (contact.LocalName == null)
            {
                throw new ArgumentException("Argument can not be null", "Contact Name");
            }

            if (string.IsNullOrEmpty(contact.DistributorID))
            {
                throw new ArgumentException("Argument can not be null", "Distributor ID");
            }

            var request = new TriggeredSendRequestRequest_V01();

            request.Data = new TriggeredSaveContactConformationSendData_V01
            {
                CustomerEmail       = contact.EmailAddresses[0].Address,
                CustomerName        = contact.LocalName,
                CustomerPhoneNumber =
                    (contact.Phones.Count > 0) ? contact.Phones.FirstOrDefault().Number : String.Empty,
                DistributorEmail    = distributorEmail,
                DistributorId       = distributorId,
                DistributorName     = distributorName,
                DataKey             = Guid.NewGuid().ToString(),
                Locale              = primaryLocale,
                Extension           = extension,
                IsDistributorCopied = isDistributorCopied,
                Domain              = domain,
                RegistrationSource  = registrationSource,
                EmailLanguageLocale = locale
            };

            using (var proxy = ServiceClientProvider.GetDistributorCRMServiceProxy())
            {
                try
                {
                    var response = proxy.SendTriggeredMessage(new SendTriggeredMessageRequest(request));
                    return(response.SendTriggeredMessageResult.Status == ServiceResponseStatusType.Success);
                }
                catch (Exception ex)
                {
                    Log(ex, proxy);
                    return(false);
                }
            }
        }
        private void BindContactValues(Contact_V01 invoiceContact)
        {
            try
            {
                if (null != invoiceContact)
                {
                    if (null != invoiceContact.EnglishName)
                    {
                        txtFirstName.Text = invoiceContact.EnglishName.First;
                        txtLastName.Text  = invoiceContact.EnglishName.Last;
                        ltName.Text       = invoiceContact.EnglishName.First + " " + invoiceContact.EnglishName.Last;
                    }

                    if (null != invoiceContact.PrimaryAddress)
                    {
                        txtAddress.Text = invoiceContact.PrimaryAddress.Line1 + " " + invoiceContact.PrimaryAddress.Line2;
                        ltAddress.Text  = invoiceContact.PrimaryAddress.Line1;
                        txtCity.Text    = invoiceContact.PrimaryAddress.City;

                        if (null != ddlState && null != ddlState.Items && ddlState.Items.Count == 0)
                        {
                            BindStatesReference();
                        }
                        ddlState.SelectedIndex =
                            ddlState.Items.IndexOf(
                                ddlState.Items.FindByValue(invoiceContact.PrimaryAddress.StateProvinceTerritory));
                        ltCityState.Text = invoiceContact.PrimaryAddress.City + ", " + invoiceContact.PrimaryAddress.StateProvinceTerritory
                                           + " " + invoiceContact.PrimaryAddress.PostalCode;
                        var arrPostalCodes = invoiceContact.PrimaryAddress.PostalCode.Split('-');
                        txtZip.Text = arrPostalCodes[0];
                        //shan - mar 07, 2012 - reset zip2 field before getting the value
                        txtZip2.Text = string.Empty;
                        if (arrPostalCodes.Length == 2)
                        {
                            txtZip2.Text = arrPostalCodes[1];
                        }
                    }

                    //shan - mar 07, 2012 - reset phone field before getting the value
                    txtPhone.Text    =
                        ltPhone.Text = string.Empty;
                    if (null != invoiceContact.Phones && invoiceContact.Phones.Count > 0)
                    {
                        var primaryPhones = invoiceContact.Phones.Where(p => p.IsPrimary);
                        if (null != primaryPhones && primaryPhones.Count() > 0 && null != primaryPhones.First())
                        {
                            txtPhone.Text = primaryPhones.First().Number;
                            ltPhone.Text  = primaryPhones.First().Number;
                        }
                        //To retrieve secondary phone when Primary phone is null.
                        if (string.IsNullOrEmpty(txtPhone.Text) && string.IsNullOrEmpty(ltPhone.Text))
                        {
                            var secondaryPhones = invoiceContact.Phones.Where(p => !p.IsPrimary);
                            if (null != secondaryPhones && secondaryPhones.Count() > 0 && null != secondaryPhones.First())
                            {
                                txtPhone.Text = secondaryPhones.First().Number;
                                ltPhone.Text  = secondaryPhones.First().Number;
                            }
                        }
                    }

                    //shan - mar 07, 2012 - reset email field before getting the value
                    txtEmail.Text    =
                        ltEmail.Text = string.Empty;
                    if (null != invoiceContact.EmailAddresses && invoiceContact.EmailAddresses.Count > 0)
                    {
                        var primaryEmails = invoiceContact.EmailAddresses.Where(e => e.IsPrimary);
                        if (null != primaryEmails && primaryEmails.Count() > 0 &&
                            null != primaryEmails.First() && null != primaryEmails.First().Address)
                        {
                            txtEmail.Text = primaryEmails.First().Address;
                            ltEmail.Text  = primaryEmails.First().Address;
                        }
                        //To retrieve secondary email when Primary email is null.
                        if (string.IsNullOrEmpty(txtEmail.Text) && string.IsNullOrEmpty(ltEmail.Text))
                        {
                            var secondaryEmails = invoiceContact.EmailAddresses.Where(e => !e.IsPrimary);
                            if (null != secondaryEmails && secondaryEmails.Count() > 0 &&
                                null != secondaryEmails.First() && null != secondaryEmails.First().Address)
                            {
                                txtEmail.Text = secondaryEmails.First().Address;
                                ltEmail.Text  = secondaryEmails.First().Address;
                            }
                        }
                    }
                    if (invoiceContact.ContactType.ToString() == "DS")
                    {
                        rbDistributor.Checked = true;
                        rbCustomer.Checked    = false;
                    }
                    else
                    {
                        rbDistributor.Checked = false;
                        rbCustomer.Checked    = true;
                    }
                    updInvoiceInfo.Update();
                }
            }
            catch (Exception ex)
            {
                MyHLWebUtil.LogExceptionWithContext(ex);
            }
        }
Example #6
0
        private static Invoice CreateInvoiceFromContact(Contact_V01 invoiceContact)
        {
            var invoice = new Invoice();

            try
            {
                if (null != invoiceContact)
                {
                    invoice.ID            = 0;
                    invoice.DistributorID = invoiceContact.DistributorID;
                    invoice.CreatedDate   = DateTime.Now;
                    invoice.InvoiceSkus   = new List <InvoiceSKU>();
                    if (null != invoiceContact.EnglishName)
                    {
                        invoice.FirstName = invoiceContact.EnglishName.First;
                        invoice.LastName  = invoiceContact.EnglishName.Last;
                    }

                    if (null != invoiceContact.PrimaryAddress)
                    {
                        invoice.Address1   = invoiceContact.PrimaryAddress.Line1;
                        invoice.Address2   = invoiceContact.PrimaryAddress.Line2;
                        invoice.City       = invoiceContact.PrimaryAddress.City;
                        invoice.State      = invoiceContact.PrimaryAddress.StateProvinceTerritory;
                        invoice.PostalCode = invoiceContact.PrimaryAddress.PostalCode;
                    }

                    if (null != invoiceContact.Phones && invoiceContact.Phones.Count > 0)
                    {
                        var primaryPhones = invoiceContact.Phones.Where(p => p.IsPrimary);

                        if (null != primaryPhones && primaryPhones.Count() > 0 && null != primaryPhones.First())
                        {
                            invoice.PhoneNumber = primaryPhones.First().Number;
                        }
                        //To retrieve secondary phone when Primary phone is null.
                        if (string.IsNullOrEmpty(invoice.PhoneNumber))
                        {
                            var secondaryPhones = invoiceContact.Phones.Where(p => !p.IsPrimary);

                            if (null != secondaryPhones && secondaryPhones.Count() > 0 && null != secondaryPhones.First())
                            {
                                invoice.PhoneNumber = secondaryPhones.First().Number;
                            }
                        }
                    }

                    if (null != invoiceContact.EmailAddresses && invoiceContact.EmailAddresses.Count > 0)
                    {
                        var primaryEmails = invoiceContact.EmailAddresses.Where(e => e.IsPrimary);

                        if (null != primaryEmails && primaryEmails.Count() > 0 &&
                            null != primaryEmails.First() && null != primaryEmails.First().Address)
                        {
                            invoice.Email = primaryEmails.First().Address;
                        }
                        //To retrieve secondary Email when Primary email is null.
                        if (string.IsNullOrEmpty(invoice.Email))
                        {
                            var secondaryEmail = invoiceContact.EmailAddresses.Where(e => !e.IsPrimary);

                            if (null != secondaryEmail && secondaryEmail.Count() > 0 &&
                                null != secondaryEmail.First() && null != secondaryEmail.First().Address)
                            {
                                invoice.Email = secondaryEmail.First().Address;
                            }
                        }
                    }
                    foreach (var phone in invoiceContact.Phones)
                    {
                        if (phone.IsPrimary)
                        {
                            invoice.PhoneNumber = phone.Number;
                        }
                        else if (phone.IsPrimary == false && !String.IsNullOrEmpty(phone.Number))
                        {
                            invoice.PhoneNumber = phone.Number;
                        }
                    }

                    foreach (var emailAddress in invoiceContact.EmailAddresses)
                    {
                        if (emailAddress.IsPrimary)
                        {
                            invoice.Email = emailAddress.Address;
                        }
                        else if (emailAddress.IsPrimary == false && !String.IsNullOrEmpty(emailAddress.Address))
                        {
                            invoice.Email = emailAddress.Address;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MyHLWebUtil.LogExceptionWithContext(ex);
            }
            return(invoice);
        }