Exemplo n.º 1
0
        public void ChangeShippingAddress(int cartId, Address address)
        {
            var service = new Core.ShoppingCartService(_context.Instance);
            var cart = service.Find(cartId);

            _context.Database.Transactional(() =>
            {
                var addr = GetOrCreateAddress(cart.Customer.Id, address);
                if (address.Id == 0)
                {
                    address.Id = addr.Id;
                }

                service.ChangeShippingAddress(cart, addr);
            });
        }
Exemplo n.º 2
0
        public int AddAddress(int customerId, Address address)
        {
            var service = new Kooboo.Commerce.Customers.CustomerService(_context.Instance);
            var customer = service.Find(customerId);
            var addr = CreateAddress(address);

            if (String.IsNullOrEmpty(addr.FirstName) && String.IsNullOrEmpty(addr.LastName))
            {
                addr.FirstName = customer.FirstName;
                addr.LastName = customer.LastName;
            }

            service.AddAddress(customer, addr);

            address.Id = addr.Id;

            return addr.Id;
        }
Exemplo n.º 3
0
 private Kooboo.Commerce.Customers.Address CreateAddress(Address addr)
 {
     return new Commerce.Customers.Address
     {
         FirstName = addr.FirstName,
         LastName = addr.LastName,
         City = addr.City,
         CountryId = addr.CountryId,
         Phone = addr.Phone,
         Postcode = addr.Postcode,
         State = addr.State,
         Address1 = addr.Address1,
         Address2 = addr.Address2
     };
 }
Exemplo n.º 4
0
        private Kooboo.Commerce.Customers.Address GetOrCreateAddress(int customerId, Address address)
        {
            var service = new Kooboo.Commerce.Customers.CustomerService(_context.Instance);
            Kooboo.Commerce.Customers.Address addr = null;

            if (address.Id > 0)
            {
                addr = service.Addresses().ById(address.Id);
            }
            else
            {
                _customerApi.AddAddress(customerId, address);
                addr = service.Addresses().ById(address.Id);
            }

            return addr;
        }