Beispiel #1
0
        public CSBusiness.CustomerManagement.Address GetAddressById(int addressId)
        {
            if (addressId == 0)
            {
                return(null);
            }

            CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection());

            var query = from c in context.Addresses
                        where c.AddressId == addressId
                        select c;
            var address = query.FirstOrDefault();

            CSBusiness.CustomerManagement.Address newAddress = new CSBusiness.CustomerManagement.Address {
                AddressId = address.AddressId
            };
            Security.Encryption.DecryptValues(newAddress);
            return(newAddress);
        }
Beispiel #2
0
        public Customer GetCustomerDetails(int customerId)
        {
            Customer item = new Customer();

            item.IsEncrpyed = true;
            using (SqlDataReader reader = CustomerDAL.GetCustomerDetails(customerId))
            {
                while (reader.Read())
                {
                    item.CustomerId       = Convert.ToInt32(reader["CustomerId"]);
                    item.FirstName        = reader["FirstName"].ToString();
                    item.LastName         = reader["LastName"].ToString();
                    item.Email            = reader["Email"].ToString();
                    item.Username         = reader["UserName"].ToString();
                    item.Active           = Convert.ToBoolean((reader["Active"]));
                    item.RegistrationDate = Convert.ToDateTime(reader["CreatedDate"]);
                    item.UserTypeId       = Convert.ToInt32(reader["UserTypeId"]);
                }

                // go to next result set to populate customer billing Address
                reader.NextResult();
                while (reader.Read())
                {
                    CSBusiness.CustomerManagement.Address billingAddress = new CSBusiness.CustomerManagement.Address();
                    billingAddress.IsEncrpyed      = true;
                    billingAddress.AddressId       = Convert.ToInt32(reader["BillingAddressId"]);
                    billingAddress.FirstName       = reader["FirstName"].ToString();
                    billingAddress.LastName        = reader["LastName"].ToString();
                    billingAddress.Address1        = reader["Address1"].ToString();
                    billingAddress.Address2        = reader["Address2"].ToString();
                    billingAddress.City            = reader["City"].ToString();
                    billingAddress.PhoneNumber     = reader["PhoneNumber"].ToString();
                    billingAddress.ZipPostalCode   = reader["ZipPostalCode"].ToString();
                    billingAddress.StateProvinceId = Convert.ToInt32(reader["StateProvince"]);
                    billingAddress.CountryId       = Convert.ToInt32(reader["CountryId"]);
                    item.BillingAddress            = billingAddress;
                }

                // go to next result set to populate customer shipping Address
                reader.NextResult();
                while (reader.Read())
                {
                    CSBusiness.CustomerManagement.Address shippingAddress = new CSBusiness.CustomerManagement.Address();
                    shippingAddress.IsEncrpyed      = true;
                    shippingAddress.AddressId       = Convert.ToInt32(reader["ShippingAddressId"]);
                    shippingAddress.FirstName       = reader["FirstName"].ToString();
                    shippingAddress.LastName        = reader["LastName"].ToString();
                    shippingAddress.Address1        = reader["Address1"].ToString();
                    shippingAddress.Address2        = reader["Address2"].ToString();
                    shippingAddress.City            = reader["City"].ToString();
                    shippingAddress.PhoneNumber     = reader["PhoneNumber"].ToString();
                    shippingAddress.ZipPostalCode   = reader["ZipPostalCode"].ToString();
                    shippingAddress.StateProvinceId = Convert.ToInt32(reader["StateProvince"]);
                    shippingAddress.CountryId       = Convert.ToInt32(reader["CountryId"]);
                    item.ShippingAddress            = shippingAddress;
                }
            }

            //Decrypy sensitive data before save
            Encryption.DecryptValues(item);

            return(item);
        }