public CustomerMatchInfoDetails GetCustomerMatchDetails(int customerId, SuppressionOptions suppressionOptions)
        {
            CustomerMatchInfoDetails      customerMatchInfoDetails = new CustomerMatchInfoDetails();
            KeyValuePair <string, string> keyValuePair             = new KeyValuePair <string, string>("PKEY", customerId.ToString());

            CustomerInfoDetails customerInfo = _customerDetailsDataAccess.GetCustomerDetails(keyValuePair, AddressType.Correspondence, suppressionOptions);

            var keys = _customerDetailsDataAccess.GetCustomerAllIndexKeys("PKEY", customerId.ToString(), "All");

            customerMatchInfoDetails.Title        = customerInfo.Title;
            customerMatchInfoDetails.FirstName    = customerInfo.FirstName;
            customerMatchInfoDetails.Surname      = customerInfo.Surname;
            customerMatchInfoDetails.Dob          = customerInfo.Dob;
            customerMatchInfoDetails.EmailAddress = customerInfo.Email;
            customerMatchInfoDetails.Homephone    = customerInfo.HomePhone;
            customerMatchInfoDetails.MobilePhone  = customerInfo.MobilePhone;
            customerMatchInfoDetails.SmsPhone     = customerInfo.SmsPhone;
            customerMatchInfoDetails.Address      = customerInfo.FullAddress;
            customerMatchInfoDetails.Postcode     = ((CorrespondenceAddress)customerInfo.Address).Postcode;
            var firstOrDefault = keys.FirstOrDefault(x => x.SourceKey == "NUME");

            if (firstOrDefault != null)
            {
                customerMatchInfoDetails.NumeroId = firstOrDefault.Keys;
            }
            var customerIndexResult = keys.FirstOrDefault(x => x.SourceKey == "TARS");

            if (customerIndexResult != null)
            {
                customerMatchInfoDetails.TaurusId = customerIndexResult.Keys;
            }
            return(customerMatchInfoDetails);
        }
        public CustomerInfoDetails GetCustomerDetail(KeyValuePair <string, string> keyValuePair,
                                                     AddressType addressType,
                                                     SuppressionOptions suppressionOptions)
        {
            var customerDetails = _customerDetailsDataAccess.GetCustomerDetails(keyValuePair, addressType, suppressionOptions);

            return(customerDetails);
        }
 public KeyValueParameter()
 {
     KeyValue = new KeyValue();
     ReturnMe = new ReturnMeForKeyValuePair();
     ResponseRequestedItems = new List <string>();
     AccessControl          = new AccessControl();
     SuppressionOptions     = new SuppressionOptions {
         IgnoreSuppression = true
     };
 }
 public NameAndAddressParameter()
 {
     NameAndAddress         = new NameAndAddress();
     ReturnMe               = new ReturnMe();
     ResponseRequestedItems = new List <string>();
     AccessControl          = new AccessControl();
     SuppressionOptions     = new SuppressionOptions {
         IgnoreSuppression = true
     };
 }
Exemplo n.º 5
0
        public List <CustomerMatchInfoDetails> GetMatchingCustomers(NameAndAddress nameAndAddress, SuppressionOptions suppressionOptions, string matchType)
        {
            CustomerMatchParameter customerMatchParameter = new CustomerMatchParameter();


            customerMatchParameter.MatchType = matchType;
            customerMatchParameter.Address1  = nameAndAddress.Address.Address1;
            customerMatchParameter.Address2  = nameAndAddress.Address.Address2;
            customerMatchParameter.Address3  = nameAndAddress.Address.Address3;
            customerMatchParameter.Address4  = nameAndAddress.Address.Address4;
            customerMatchParameter.Postcode  = nameAndAddress.Address.Postcode;
            customerMatchParameter.Dob       = nameAndAddress.Dob;
            customerMatchParameter.Phone     = nameAndAddress.Phone;
            customerMatchParameter.Email     = nameAndAddress.Email;
            customerMatchParameter.FirstName = nameAndAddress.FirstName;
            customerMatchParameter.Surname   = nameAndAddress.Surname;
            customerMatchParameter.Title     = nameAndAddress.Title;

            List <MatchedCustomer> matchedCustomers = _customerDataAccess.GetMatchingCustomers(customerMatchParameter);

            List <CustomerMatchInfoDetails> customerMatchDetails = new List <CustomerMatchInfoDetails>();

            foreach (var c in matchedCustomers)
            {
                customerMatchDetails.Add(_customerDataAccess.GetCustomerMatchDetails(c.CustomerId, suppressionOptions));
            }

            return(customerMatchDetails);
        }
        public CustomerInfoDetails GetCustomerDetails(KeyValuePair <string, string> kvPair,
                                                      AddressType addressType,
                                                      SuppressionOptions suppressionOptions
                                                      )
        {
            CustomerInfoDetails infoDetails = new CustomerInfoDetails();

            using (var conn = new SqlConnection(MciCrDbConnectionString))
            {
                using (var cmd = new SqlCommand("[dbo].[GetCustomerDetails]", conn))
                {
                    try
                    {
                        cmd.Connection.Open();

                        cmd.Parameters.Add(
                            new SqlParameter("@key", SqlDbType.VarChar, 4).SetSqlValue(kvPair.Key)
                            );

                        var param1Value = "";
                        if (!string.IsNullOrWhiteSpace(kvPair.Key))
                        {
                            if (kvPair.Key.Equals(SourceKey.ACTI.ToString(), StringComparison.OrdinalIgnoreCase) ||
                                kvPair.Key.Equals(SourceKey.MEMB.ToString(), StringComparison.OrdinalIgnoreCase))
                            {
                                var value = kvPair.Value;
                                if (value.Contains(" "))
                                {
                                    value = value.Replace(" ", "+");
                                }

                                param1Value = HttpUtility.UrlEncode(value);
                            }
                            else
                            {
                                param1Value = kvPair.Value;
                            }
                        }
                        else
                        {
                            param1Value = kvPair.Value;
                        }
                        cmd.Parameters.Add(new SqlParameter("@value", SqlDbType.VarChar, 40).SetSqlValue(param1Value));
                        cmd.Parameters.Add(new SqlParameter("@addressFormat", SqlDbType.VarChar, 15).SetSqlValue(addressType));

                        // Suppression parameter
                        cmd.Parameters.Add(
                            new SqlParameter("@ignoreSuppression", SqlDbType.Bit).SetSqlValue(suppressionOptions.IgnoreSuppression.ToInt())
                            );

                        if (!IsCustomerExists(kvPair.Key, kvPair.Value, "PKEY"))
                        {
                            return(null);
                        }

                        cmd.CommandType = CommandType.StoredProcedure;
                        var table        = new DataTable();
                        var adapter      = new SqlDataAdapter(cmd);
                        var affectedRows = adapter.Fill(table);
                        if (affectedRows == 0)
                        {
                            return(null);
                        }

                        infoDetails = BuildCustomerDetails(table.Rows, addressType);
                    }
                    catch (SqlException ex)
                    {
                        _logger.Error("CustomerDetailsDataAccess: " + "ErrorTag: " + ErrorTagProvider.ErrorTagDatabase + " -- " + ex.Message, ex);
                        throw new Exception(string.Format(DatabaseMessage.DatabaseException, ErrorTagProvider.ErrorTagDatabase));
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("CustomerDetailsDataAccess: " + "ErrorTag: " + ErrorTagProvider.ErrorTagDatabase + " -- " + ex.Message, ex);
                        throw new Exception(string.Format(DatabaseMessage.DatabaseException, ErrorTagProvider.ErrorTagDatabase));
                    }
                }
            }
            return(infoDetails);
        }