Exemple #1
0
        public static List <CustomerInfo> GetCustomers(int storeId)
        {
            //OrderQuery q = new OrderQuery();
            //q.es.Distinct = true;
            //q.Select(q.UserId);
            //q.Where(q.StoreId == storeId, q.UserId.IsNotNull());
            //OrderCollection orderUsers = new OrderCollection();
            //orderUsers.Load(q);

            //Dictionary<int,bool> orderUserIdHash = new Dictionary<int, bool>(orderUsers.Count);
            //((List<Order>)orderUsers).ForEach(o => orderUserIdHash[o.UserId.Value] = true);

            //Store theStore = GetStore(storeId);
            //ArrayList userArray = UserController.GetUsers(theStore.PortalId.Value); // Normal Users
            //userArray.AddRange(UserController.GetUsers(Null.NullInteger));  // Super Users

            //List<UserInfo> userInfos = userArray.ToList<UserInfo>();
            //userInfos.RemoveAll(ui => !orderUserIdHash.ContainsKey(ui.UserID));

            //return userInfos;

            OrderQuery q = new OrderQuery();

            q.es.Distinct = true;
            q.Select(
                q.UserId,
                q.CustomerFirstName,
                q.CustomerLastName,
                q.CustomerEmail,
                q.BillAddress1,
                q.BillAddress2,
                q.BillCity,
                q.BillRegion,
                q.BillPostalCode,
                q.BillCountryCode,
                q.BillTelephone,
                q.ShipRecipientName,
                q.ShipRecipientBusinessName,
                q.ShipAddress1,
                q.ShipAddress2,
                q.ShipCity,
                q.ShipRegion,
                q.ShipPostalCode,
                q.ShipCountryCode,
                q.ShipTelephone
                );
            q.Where(q.StoreId == storeId);

            OrderCollection collection = new OrderCollection();

            collection.Load(q);
            List <Order> orders = collection.ToList();

            List <CustomerInfo> customerInfos = orders.ConvertAll(c => new CustomerInfo()
            {
                UserId                    = c.UserId,
                FirstName                 = c.CustomerFirstName,
                LastName                  = c.CustomerLastName,
                Email                     = c.CustomerEmail,
                BillAddress1              = c.BillAddress1,
                BillAddress2              = c.BillAddress2,
                BillCity                  = c.BillCity,
                BillRegion                = c.BillRegion,
                BillPostalCode            = c.BillPostalCode,
                BillCountryCode           = c.BillCountryCode,
                BillTelephone             = c.BillTelephone,
                ShipRecipientName         = c.ShipRecipientName,
                ShipRecipientBusinessName = c.ShipRecipientBusinessName,
                ShipAddress1              = c.ShipAddress1,
                ShipAddress2              = c.ShipAddress2,
                ShipCity                  = c.ShipCity,
                ShipRegion                = c.ShipRegion,
                ShipPostalCode            = c.ShipPostalCode,
                ShipCountryCode           = c.ShipCountryCode,
                ShipTelephone             = c.ShipTelephone
            });

            return(customerInfos);
        }