コード例 #1
0
        public ShoppingCartEntity GetShoppingCartById(string id)
        {
            var query = ShoppingCarts.Include(x => x.TaxDetails)
                        .Include(x => x.Discounts)
                        .Where(x => x.Id == id);
            var addresses = Addresses.Where(x => x.ShoppingCartId == id).ToArray();
            var payments  = Payments.Include(x => x.Addresses).Where(x => x.ShoppingCartId == id).ToArray();
            var lineItems = LineItems.Include(x => x.Discounts)
                            .Include(x => x.TaxDetails)
                            .Where(x => x.ShoppingCartId == id).ToArray();
            var shipments = Shipments.Include(x => x.TaxDetails)
                            .Include(x => x.Discounts)
                            .Where(x => x.ShoppingCartId == id).ToArray();

            return(query.FirstOrDefault());
        }
コード例 #2
0
        public virtual CustomerOrderEntity[] GetCustomerOrdersByIds(string[] ids, CustomerOrderResponseGroup responseGroup)
        {
            var query = CustomerOrders.Where(x => ids.Contains(x.Id))
                        .Include(x => x.Discounts)
                        .Include(x => x.TaxDetails);

            if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses)
            {
                var addresses = Addresses.Where(x => ids.Contains(x.CustomerOrderId)).ToArray();
            }
            if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments)
            {
                var inPayments = InPayments.Include(x => x.TaxDetails)
                                 .Include(x => x.Discounts)
                                 .Where(x => ids.Contains(x.CustomerOrderId)).ToArray();
                var paymentsIds      = inPayments.Select(x => x.Id).ToArray();
                var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray();
                var transactions     = Transactions.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray();
            }
            if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems)
            {
                var lineItems = LineItems.Include(x => x.TaxDetails)
                                .Include(x => x.Discounts)
                                .Where(x => ids.Contains(x.CustomerOrderId)).ToArray();
            }
            if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments)
            {
                var shipments = Shipments.Include(x => x.TaxDetails)
                                .Include(x => x.Discounts)
                                .Include(x => x.Items)
                                .Include(x => x.Packages.Select(y => y.Items))
                                .Where(x => ids.Contains(x.CustomerOrderId)).ToArray();
                var shipmentIds = shipments.Select(x => x.Id).ToArray();
                var addresses   = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray();
            }
            return(query.ToArray());
        }