MigrateCart() public method

public MigrateCart ( ShoppingCart from, ShoppingCart to ) : void
from ShoppingCart
to ShoppingCart
return void
Esempio n. 1
0
        public void MigrateCart(int customerId, string session)
        {
            var service     = new Core.ShoppingCartService(_context.Instance);
            var sessionCart = service.FindBySessionId(session);

            if (sessionCart == null)
            {
                return;
            }

            var customerCart = service.FindByCustomerId(customerId);

            if (customerCart == null)
            {
                var customer = _context.Database.Repository <Kooboo.Commerce.Customers.Customer>().Find(customerId);
                customerCart = Kooboo.Commerce.Carts.ShoppingCart.Create(customer, session);
                service.Create(customerCart);
            }

            service.MigrateCart(sessionCart, customerCart);
        }
Esempio n. 2
0
        public void MigrateCart(int customerId, string session)
        {
            var service = new Core.ShoppingCartService(_context.Instance);
            var sessionCart = service.FindBySessionId(session);
            if (sessionCart == null)
            {
                return;
            }

            var customerCart = service.FindByCustomerId(customerId);
            if (customerCart == null)
            {
                var customer = _context.Database.Repository<Kooboo.Commerce.Customers.Customer>().Find(customerId);
                customerCart = Kooboo.Commerce.Carts.ShoppingCart.Create(customer, session);
                service.Create(customerCart);
            }

            service.MigrateCart(sessionCart, customerCart);
        }