Kooboo.Commerce.Carts.ShoppingCartService.FindByCustomerId C# (CSharp) Method

FindByCustomerId() public method

public FindByCustomerId ( int customerId ) : ShoppingCart
customerId int
return ShoppingCart
        public ShoppingCart FindByCustomerId(int customerId)
        {
            return Query().FirstOrDefault(c => c.Customer != null && c.Customer.Id == customerId);
        }

Usage Example

        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);
        }
All Usage Examples Of Kooboo.Commerce.Carts.ShoppingCartService::FindByCustomerId