//DTO
        public CustomerAccountDTO ToDto()
        {
            CustomerAccountDTO dto = new CustomerAccountDTO();

            dto.Bvin = this.Bvin;
            dto.Email = this.Email;
            dto.FirstName = this.FirstName;
            dto.LastName = this.LastName;
            dto.Password = this.Password;
            dto.Salt = this.Salt;

            dto.TaxExempt = this.TaxExempt;
            dto.Notes = this.Notes;
            dto.PricingGroupId = this.PricingGroupId;

            dto.FailedLoginCount = this.FailedLoginCount;

            dto.LastUpdatedUtc = this.LastUpdatedUtc;
            dto.CreationDateUtc = this.CreationDateUtc;
            dto.LastLoginDateUtc = this.LastLoginDateUtc;

            foreach (Contacts.Address a in this.Addresses)
            {
                dto.Addresses.Add(a.ToDto());
            }

            dto.ShippingAddress = this.ShippingAddress.ToDto();
            dto.BillingAddress = this.BillingAddress.ToDto();
            return dto;
        }
        public void FromDto(CustomerAccountDTO dto)
        {
            this.Bvin = dto.Bvin;
            this.Email = dto.Email;
            this.FirstName = dto.FirstName;
            this.LastName = dto.LastName;
            this.Password = dto.Password;
            this.Salt = dto.Salt;

            this.TaxExempt = dto.TaxExempt;
            this.Notes = dto.Notes;
            this.PricingGroupId = dto.PricingGroupId;

            this.FailedLoginCount = dto.FailedLoginCount;

            this.LastUpdatedUtc = dto.LastUpdatedUtc;
            this.CreationDateUtc = dto.CreationDateUtc;
            this.LastLoginDateUtc = dto.LastLoginDateUtc;

            foreach (AddressDTO a in dto.Addresses)
            {
                Contacts.Address addr = new Contacts.Address();
                addr.FromDto(a);
                this.Addresses.Add(addr);
            }

            this.ShippingAddress.FromDto(dto.ShippingAddress);
            this.BillingAddress.FromDto(dto.BillingAddress);
        }
Exemple #3
0
        private void ImportSingleUser(data.bvc_User u)
        {
            if (u == null)
            {
                wl("Customer was null!");
                return;
            }
            wl("Importing Customer: " + u.Email);

            CustomerAccountDTO customer = new CustomerAccountDTO();
            customer.Bvin = u.ID.ToString();
            customer.CreationDateUtc = u.CreationDate;
            customer.Email = u.Email;
            customer.FailedLoginCount = 0;
            customer.FirstName = u.FirstName;
            customer.LastLoginDateUtc = u.LastLoginDate;
            customer.LastName = u.LastName;
            customer.LastUpdatedUtc = DateTime.UtcNow;
            customer.Notes = u.Comment;
            customer.Password = string.Empty;
            customer.PricingGroupId = string.Empty;            
            if (u.PricingLevel > 0)
            {
                customer.PricingGroupId = "BVC2004" + u.PricingLevel.ToString().Trim();
            }
            customer.Salt = string.Empty;
            customer.TaxExempt = u.TaxExempt == 1 ? true : false;
            customer.Addresses = new List<AddressDTO>();

            // Preserve clear text passwords
            string newPassword = u.Password;
            customer.Password = newPassword;


            List<BVC2004Address> addresses = BVC2004Address.ReadAddressesFromXml(u.AddressBook);
            if (addresses != null)
            {
                foreach (BVC2004Address a in addresses)
                {
                    AddressDTO addr = new AddressDTO();
                    addr.AddressType = AddressTypesDTO.BillingAndShipping;
                    a.CopyTo(addr, EFConnString(settings.SourceConnectionString())); ;
                    customer.Addresses.Add(addr);
                }
            }

            Api bv6proxy = GetBV6Proxy();
            var res = bv6proxy.CustomerAccountsCreateWithPassword(customer, newPassword);
            if (res != null)
            {
                if (res.Errors.Count > 0)
                {
                    DumpErrors(res.Errors);
                    return;
                }
                wl("SUCCESS");
            }
        }
Exemple #4
0
 //private void ProcessPage(int i)
 //{
 //    wl("Getting Users page " + (i + 1));
 //    int startRecord = i * 100;
 //    var users = (from u in oldDatabase.bvc_User select u).OrderBy(y => y.Email).Skip(startRecord).Take(100).ToList();
 //    foreach (data.bvc_User u in users)
 //    {
 //        ImportSingleUser(u);
 //    }
 //}
 private void ImportSingleUser(CustomerAccountDTO u)
 {
     if (u == null)
     {
         wl("Customer was null!");
         return;
     }
     wl("Importing Customer: " + u.Email);            
     Api bv6proxy = GetMerchantTribeProxy();
     var res = bv6proxy.CustomerAccountsCreate(u);            
     if (res != null)
     {
         if (res.Errors.Count > 0)
         {
             DumpErrors(res.Errors);
             return;
         }
         wl("SUCCESS");
     }
 }
Exemple #5
0
        private void ImportSingleUser(data.bvc_User u)
        {
            if (u == null)
            {
                wl("Customer was null!");
                return;
            }
            wl("Importing Customer: " + u.Email);

            CustomerAccountDTO customer = new CustomerAccountDTO();
            customer.Bvin = u.bvin;
            customer.CreationDateUtc = u.CreationDate;
            customer.Email = u.Email;
            customer.FailedLoginCount = u.FailedLoginCount;
            customer.FirstName = u.FirstName;
            customer.LastLoginDateUtc = u.LastLoginDate;
            customer.LastName = u.LastName;
            customer.LastUpdatedUtc = u.LastUpdated;
            customer.Notes = u.Comment;
            customer.Password = string.Empty;
            customer.PricingGroupId = u.PricingGroup;
            customer.Salt = string.Empty;
            customer.TaxExempt = u.TaxExempt == 1 ? true : false;
            customer.Addresses = new List<AddressDTO>();

            // Preserve clear text passwords
            string newPassword = string.Empty;
            if (u.PasswordFormat == 0)
            {
                newPassword = u.Password;
            }

            BV5Address shipping = new BV5Address();
            shipping.FromXmlString(u.ShippingAddress);
            AddressDTO ship = new AddressDTO();
            ship.AddressType = AddressTypesDTO.Shipping;
            shipping.CopyTo(ship, EFConnString(settings.SourceConnectionString()));
            customer.Addresses.Add(ship);

            BV5Address billing = new BV5Address();
            billing.FromXmlString(u.BillingAddress);
            AddressDTO bill = new AddressDTO();
            bill.AddressType = AddressTypesDTO.Billing;
            billing.CopyTo(bill, EFConnString(settings.SourceConnectionString()));
            customer.Addresses.Add(bill);

            List<BV5Address> addresses = BV5Address.ReadAddressesFromXml(u.AddressBook);
            foreach (BV5Address addr in addresses)
            {
                AddressDTO a = new AddressDTO();
                a.AddressType = AddressTypesDTO.General;
                addr.CopyTo(a, EFConnString(settings.SourceConnectionString()));
                customer.Addresses.Add(a);
            }

            Api bv6proxy = GetBV6Proxy();
            var res = bv6proxy.CustomerAccountsCreateWithPassword(customer, newPassword);
            if (res != null)
            {
                if (res.Errors.Count > 0)
                {
                    DumpErrors(res.Errors);
                    return;
                }
                wl("SUCCESS");
            }
        }
Exemple #6
0
 public ApiResponse<CustomerAccountDTO> CustomerAccountsUpdate(CustomerAccountDTO item)
 {
     ApiResponse<CustomerAccountDTO> result = new ApiResponse<CustomerAccountDTO>();
     result = RestHelper.PostRequest<ApiResponse<CustomerAccountDTO>>(this.fullApiUri + "customeraccounts/" + Enc(item.Bvin) + "?key=" + Enc(key), MerchantTribe.Web.Json.ObjectToJson(item));
     return result;
 }
Exemple #7
0
 public ApiResponse<CustomerAccountDTO> CustomerAccountsCreateWithPassword(CustomerAccountDTO item, string clearpassword)
 {
     ApiResponse<CustomerAccountDTO> result = new ApiResponse<CustomerAccountDTO>();
     result = RestHelper.PostRequest<ApiResponse<CustomerAccountDTO>>(this.fullApiUri + "customeraccounts/?key=" + Enc(key) + "&pwd=" + Enc(clearpassword), MerchantTribe.Web.Json.ObjectToJson(item));
     return result;
 }