コード例 #1
0
        public static List <Customer> GetNewestDistributors(GetNewestDistributorsRequest request)
        {
            var query = Exigo.OData().UniLevelTree.Expand("Customer")
                        .Where(c => c.TopCustomerID == request.CustomerID && c.Customer.CustomerTypeID == (int)CustomerTypes.Associate)
                        .Where(c => c.Level <= request.MaxLevel)
                        .OrderByDescending(c => c.Customer.CreatedDate).Take(request.RowCount).ToList();

            var customers = query.Select(c => (Customer)c.Customer).ToList();

            return(customers);
        }
コード例 #2
0
        //Only Used for the Dashboard Card... Really all this does is return the customerID's then lets the customer model pull the avatar URL.
        public static List <Customer> GetNewestDistributors(GetNewestDistributorsRequest request)
        {
            var newestDistributors = new List <Customer>();
            var customerTypes      = request.CustomerTypes;
            var customerStatuses   = request.CustomerStatuses;

            using (var context = ExigoDAL.Sql())
            {
                newestDistributors = context.Query <Customer>(@"
                                SELECT TOP (@RowCount) un.DownlineCustomerID
	                                  , c.CustomerID
                                      , c.FirstName
                                      , c.MiddleName
                                      , c.LastName
                                      , c.CreatedDate
                                      , c.Phone AS PrimaryPhone
                                      , c.Email
                                FROM UniLevelDownline un
	                                LEFT JOIN Customers c
		                                ON un.CustomerID = c.CustomerID
                                WHERE un.DownlineCustomerID = @CustomerID
                                    AND c.CustomerID <> @CustomerID
	                                AND un.Level <= @Level
                                    AND c.CustomerTypeID IN @CustomerTypes
                                    AND c.CustomerStatusID IN @CustomerStatuses
                                    AND c.CreatedDate >= CASE 
                                        WHEN @days > 0 
                                        THEN getdate()-@Days 
                                        ELSE c.CreatedDate 
                                        END
                                ORDER BY CreatedDate
                    ", new
                {
                    CustomerID       = request.CustomerID,
                    Level            = request.MaxLevel,
                    RowCount         = request.RowCount,
                    CustomerTypes    = customerTypes,
                    CustomerStatuses = customerStatuses,
                    Days             = request.Days
                }).ToList();
            }

            return(newestDistributors);
        }