public static bool IsEmailAvailable(string email)
 {
     // Validate the email address
     return(Exigo.OData().Customers
            .Where(c => c.Email == email)
            .Count() == 0);
 }
示例#2
0
        public static VolumeCollection GetCustomerVolumes(GetCustomerVolumesRequest request)
        {
            //2015-08-04
            //Ivan Sanchez
            //60
            //Added the changes Travis and I did for PHP to avoid the dashboard error
            var requestedSpecificVolumes = (request.VolumeIDs != null && request.VolumeIDs.Length > 0);

            var baseQuery = Exigo.OData().PeriodVolumes.Expand("Period,Rank,PaidRank");
            var query     = baseQuery
                            .Where(c => c.CustomerID == request.CustomerID)
                            .Where(c => c.PeriodTypeID == request.PeriodTypeID);

            // Determine which period ID to use
            if (request.PeriodID != null)
            {
                query = query.Where(c => c.PeriodID == (int)request.PeriodID);
            }
            else
            {
                query = query.Where(c => c.Period.IsCurrentPeriod);
            }

            var data   = query.FirstOrDefault();
            var result = (VolumeCollection)data;

            return(result);
        }
示例#3
0
        public static IEnumerable <WaitingRoomNode> GetCustomerWaitingRoom(GetCustomerWaitingRoomRequest request)
        {
            var customers = Exigo.OData().EnrollerTree
                            .Where(c => c.TopCustomerID == request.EnrollerID)
                            .Where(c => c.Customer.SponsorID == null)
                            .Where(c => c.Customer.CustomerStatusID == CustomerStatuses.Active)
                            .Where(c => c.Customer.Field1 == string.Empty)
                            .OrderByDescending(c => c.Customer.CreatedDate)
                            .Select(c => new WaitingRoomNode()
            {
                CustomerID     = c.CustomerID,
                FirstName      = c.Customer.FirstName,
                LastName       = c.Customer.LastName,
                EnrollerID     = c.EnrollerID,
                EnrollmentDate = c.Customer.CreatedDate,
                City           = c.Customer.MainCity,
                State          = c.Customer.MainState,
                Country        = c.Customer.MainCountry,
                Phone          = c.Customer.Phone,
                Email          = c.Customer.Email
            })
                            .ToList();

            // Filter out the customer that are no longer placeable
            customers = customers.Where(c => c.EnrollmentDate.AddDays(request.GracePeriod) > DateTime.Now).ToList();

            return(customers);
        }
示例#4
0
 // Validators
 public static bool IsPersonallyEnrolled(int topCustomerID, int customerID)
 {
     return(Exigo.OData().EnrollerTree
            .Where(c => c.TopCustomerID == topCustomerID)
            .Where(c => c.CustomerID == customerID)
            .Count() != 0);
 }
示例#5
0
        public static List <WaitingRoomNode> GetWaitingRoomNodes(GetCustomerWaitingRoomRequest request)
        {
            var customers = Exigo.OData().Customers
                            .Where(c => c.EnrollerID == request.EnrollerID)
                            .Where(c => c.SponsorID == null)
                            .Where(c => c.CustomerStatusID == (int)CustomerStatusTypes.Active)
                            .Where(c => c.CustomerTypeID == (int)CustomerTypes.Distributor)
                            .ToList();

            var nodes = new List <WaitingRoomNode>();

            foreach (var customer in customers)
            {
                var node = new WaitingRoomNode();
                node.CustomerID     = customer.CustomerID;
                node.Email          = customer.Email;
                node.EnrollerID     = customer.EnrollerID;
                node.EnrollmentDate = customer.CreatedDate;
                node.FirstName      = customer.FirstName;
                node.LastName       = customer.LastName;
                node.Phone          = customer.Phone;

                nodes.Add(node);
            }
            return(nodes);
        }
示例#6
0
 public static bool IsCustomerInBinaryTree(int customerID, int topCustomerID)
 {
     return(Exigo.OData().BinaryTree
            .Where(c => c.TopCustomerID == topCustomerID)
            .Where(c => c.CustomerID == customerID)
            .Count() != 0);
 }
示例#7
0
        public static HistoricalCommission GetCustomerHistoricalCommission(int customerID, int commissionRunID)
        {
            // Get the commission record
            var commission = Exigo.OData().Commissions.Expand("CommissionRun/Period").Expand("PaidRank")
                             .Where(c => c.CustomerID == customerID)
                             .Where(c => c.CommissionRunID == commissionRunID)
                             .FirstOrDefault();

            if (commission == null)
            {
                return(null);
            }
            var result = (HistoricalCommission)commission;


            // Get the volumes
            result.Volumes = GetCustomerVolumes(new GetCustomerVolumesRequest
            {
                CustomerID   = customerID,
                PeriodID     = result.Period.PeriodID,
                PeriodTypeID = result.Period.PeriodTypeID,
                VolumeIDs    = new int[] { 1, 2, 3, 4, 5 }
            });

            return(result);
        }
示例#8
0
        public static CustomerSite GetCustomerSite(int customerID)
        {
            try
            {
                var site = Exigo.OData().CustomerSites
                           .Where(c => c.CustomerID == customerID)
                           .FirstOrDefault();
                if (site == null)
                {
                    return(null);
                }

                return((CustomerSite)site);
            }
            catch (Exception exception)
            {
                if (exception.Message == "CustomerSite not found\n")
                {
                    return(null);
                }
                else
                {
                    throw exception;
                }
            }
        }
        public static IEnumerable <Country> GetCountries()
        {
            var context = Exigo.OData();
            var records = new List <Country>();

            // Get the nodes recursively until we have them all
            int resultsPerCall  = 50;
            int lastResultCount = resultsPerCall;
            int callsMade       = 0;

            while (lastResultCount == resultsPerCall)
            {
                var results = context.Countries
                              .OrderBy(c => c.SortOrder)
                              .Skip(callsMade * resultsPerCall)
                              .Take(resultsPerCall)
                              .Select(c => c)
                              .ToList();

                results.ForEach(c => records.Add((Country)c));

                callsMade++;
                lastResultCount = results.Count;
            }

            foreach (var record in records)
            {
                yield return(record);
            }
        }
示例#10
0
        public static IEnumerable <Subscription> GetSubscriptions()
        {
            var subscriptions = Exigo.OData().Subscriptions.ToList();

            foreach (var subscription in subscriptions)
            {
                yield return((ExigoService.Subscription)subscription);
            }
        }
示例#11
0
        public List <string> GetCustomerAvatarHistory(int customerID)
        {
            var path   = "/customers/{0}/avatars".FormatWith(customerID);
            var images = Exigo.OData().ImageFiles
                         .Where(c => c.Path == path)
                         .ToList();

            return(images.Select(c => c.Url).ToList());
        }
        public static IEnumerable <PointAccount> GetPointAccounts()
        {
            var pointAccounts = Exigo.OData().PointAccounts.ToList();

            foreach (var pointAccount in pointAccounts)
            {
                yield return((ExigoService.PointAccount)pointAccount);
            }
        }
示例#13
0
文件: Ranks.cs 项目: Webalap/W-ALAP
        public static Rank GetRank(int rankID)
        {
            var context = Exigo.OData();
            var apiRank = context.Ranks
                          .Where(c => c.RankID == rankID)
                          .FirstOrDefault();

            return((Rank)apiRank);
        }
示例#14
0
        public static IEnumerable <CustomerSubscription> GetCustomerSubscriptions(int customerID)
        {
            var subscriptions = Exigo.OData().CustomerSubscriptions.Expand("Subscription,SubscriptionStatus")
                                .ToList();

            foreach (var subscription in subscriptions)
            {
                yield return((ExigoService.CustomerSubscription)subscription);
            }
        }
示例#15
0
        public static IEnumerable <CustomerPointAccount> GetCustomerPointAccounts(int customerID)
        {
            var pointAccounts = Exigo.OData().CustomerPointAccounts.Expand("PointAccount")
                                .ToList();

            foreach (var pointAccount in pointAccounts)
            {
                yield return((ExigoService.CustomerPointAccount)pointAccount);
            }
        }
示例#16
0
文件: Ranks.cs 项目: Webalap/W-ALAP
        public static IEnumerable <Rank> GetRanks()
        {
            var context  = Exigo.OData();
            var apiRanks = context.Ranks
                           .OrderBy(c => c.RankID);

            foreach (var apiRank in apiRanks)
            {
                yield return((Rank)apiRank);
            }
        }
示例#17
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);
        }
示例#18
0
        public static IEnumerable <Period> GetPeriods(GetPeriodsRequest request)
        {
            var context = Exigo.OData();

            // Setup the query
            var query = context.Periods
                        .Where(c => c.PeriodTypeID == request.PeriodTypeID);

            if (request.PeriodIDs.Length > 0)
            {
                query = query.Where(request.PeriodIDs.ToList().ToOrExpression <Common.Api.ExigoOData.Period, int>("PeriodID"));
            }

            // Optionally filter by the customer.
            // If the customer is provided, only periods the customer was a part of will be returned.
            if (request.CustomerID != null)
            {
                var customer = context.Customers
                               .Where(c => c.CustomerID == (int)request.CustomerID)
                               .Select(c => new { c.CreatedDate })
                               .FirstOrDefault();
                if (customer != null)
                {
                    query = query.Where(c => c.EndDate >= customer.CreatedDate);
                }
            }


            // Get the data
            var periods = new List <Common.Api.ExigoOData.Period>();

            int lastResultCount = 50;
            int callsMade       = 0;

            while (lastResultCount == 50)
            {
                var results = query.Select(c => c)
                              .Skip(callsMade * 50)
                              .Take(50)
                              .Select(c => c)
                              .ToList();

                results.ForEach(c => periods.Add(c));

                callsMade++;
                lastResultCount = results.Count;
            }


            foreach (var period in periods)
            {
                yield return((Period)period);
            }
        }
示例#19
0
        public static bool IsCustomerInUniLevelDownline(int topCustomerID, int customerID)
        {
            if (customerID == topCustomerID)
            {
                return(true);
            }

            return(Exigo.OData().UniLevelTree
                   .Where(c => c.TopCustomerID == topCustomerID)
                   .Where(c => c.CustomerID == customerID)
                   .Count() != 0);
        }
示例#20
0
        public static IEnumerable <T> GetGenealogyTree <T>(GetTreeRequest request) where T : ITreeNode
        {
            // Get the nodes
            var nodes           = new List <T>();
            var rowcount        = 50;
            var lastResultCount = rowcount;
            var callsMade       = 0;

            while (lastResultCount == rowcount)
            {
                var query = Exigo.OData().EnrollerTree
                            .Where(c => c.TopCustomerID == request.TopCustomerID);

                // Filter by level
                var levels = (request.Levels != 0) ? request.Levels : 10;
                query = query
                        .Where(c => c.Level <= levels);

                // Filter by customer types
                var allowableCustomerTypes = new List <int>()
                {
                    (int)CustomerTypes.Associate
                };
                query = query
                        .Where(allowableCustomerTypes.ToOrExpression <EnrollerNode, int>("Customer.CustomerTypeID"));

                // Get the data
                var results = query
                              .OrderBy(c => c.IndentedSort)
                              .Skip(callsMade * rowcount)
                              .Take(rowcount)
                              .Select(c => c)
                              .ToList();

                results.ForEach(c =>
                {
                    var node              = (T)Activator.CreateInstance(typeof(T));
                    node.CustomerID       = c.CustomerID;
                    node.ParentCustomerID = c.EnrollerID;
                    node.Level            = c.Level;
                    node.PlacementID      = 0;
                    node.IndentedSort     = c.IndentedSort;
                    node.ChildNodeCount   = c.ChildCount;

                    nodes.Add(node);
                });

                callsMade++;
                lastResultCount = results.Count;
            }

            return(nodes);
        }
示例#21
0
        private static CreateAutoOrderRequest GetCreateOverridenAutoOrderRequest(int customerID, int autoOrderID)
        {
            // Get the autoorder
            var context   = Exigo.OData();
            var autoOrder = context.AutoOrders.Expand("Details")
                            .Where(c => c.CustomerID == customerID)
                            .Where(c => c.AutoOrderID == autoOrderID)
                            .FirstOrDefault();

            // Re-create the autoorder
            return(new CreateAutoOrderRequest(autoOrder));
        }
示例#22
0
        public static VolumeCollection GetCustomerVolumes(GetCustomerVolumesRequest request)
        {
            var requestedSpecificVolumes = (request.VolumeIDs != null && request.VolumeIDs.Length > 0);

            var baseQuery = Exigo.OData().PeriodVolumes;
            var query     = baseQuery
                            .Where(c => c.CustomerID == request.CustomerID)
                            .Where(c => c.PeriodTypeID == request.PeriodTypeID);

            // Determine which period ID to use
            if (request.PeriodID != null)
            {
                query = query.Where(c => c.PeriodID == (int)request.PeriodID);
            }
            else
            {
                query = query.Where(c => c.Period.IsCurrentPeriod);
            }

            PeriodVolume data;

            if (!requestedSpecificVolumes)
            {
                data = query.Select(c => new Common.Api.ExigoOData.PeriodVolume()
                {
                    CustomerID   = c.CustomerID,
                    ModifiedDate = c.ModifiedDate,
                    PaidRankID   = c.PaidRankID,
                    PaidRank     = c.PaidRank,
                    RankID       = c.RankID,
                    Rank         = c.Rank,
                    PeriodID     = c.PeriodID,
                    Period       = c.Period,
                    PeriodTypeID = c.PeriodTypeID
                }).FirstOrDefault();
            }
            else
            {
                var volumes = new List <string>();
                foreach (var id in request.VolumeIDs)
                {
                    volumes.Add("Volume" + id);
                }
                var select     = string.Format("new({0},Period,Rank,PaidRank)", string.Join(",", volumes));
                var finalQuery = query.Select(select);

                var url = finalQuery.ToString();
                data = Exigo.OData().Execute <Common.Api.ExigoOData.PeriodVolume>(new Uri(url)).FirstOrDefault();
            }

            return((VolumeCollection)data);
        }
示例#23
0
文件: Ranks.cs 项目: Webalap/W-ALAP
        public static CustomerRankCollection GetCustomerRanks(GetCustomerRanksRequest request)
        {
            var result  = new CustomerRankCollection();
            var context = Exigo.OData();

            // Get the highest rank achieved in the customer table
            var highestRankAchieved = context.Customers
                                      .Where(c => c.CustomerID == request.CustomerID)
                                      .Select(c => new
            {
                c.Rank
            }).FirstOrDefault();

            if (highestRankAchieved != null)
            {
                result.HighestPaidRankInAnyPeriod = (Rank)highestRankAchieved.Rank;
            }

            // Get the period ranks
            var query = context.PeriodVolumes
                        .Where(c => c.CustomerID == request.CustomerID)
                        .Where(c => c.PeriodTypeID == request.PeriodTypeID);

            if (request.PeriodID != null)
            {
                query = query.Where(c => c.PeriodID == (int)request.PeriodID);
            }
            else
            {
                query = query.Where(c => c.Period.IsCurrentPeriod);
            }

            var periodRanks = query.Select(c => new
            {
                c.Rank,
                c.PaidRank
            }).FirstOrDefault();

            if (periodRanks != null)
            {
                if (periodRanks.PaidRank != null)
                {
                    result.CurrentPeriodRank = (Rank)periodRanks.PaidRank;
                }
                if (periodRanks.Rank != null)
                {
                    result.HighestPaidRankUpToPeriod = (Rank)periodRanks.Rank;
                }
            }

            return(result);
        }
示例#24
0
        public static Subscription GetSubscription(int subscriptionID)
        {
            var subscription = Exigo.OData().Subscriptions
                               .Where(c => c.SubscriptionID == subscriptionID)
                               .FirstOrDefault();

            if (subscription == null)
            {
                return(null);
            }

            return((ExigoService.Subscription)subscription);
        }
示例#25
0
        public static CustomerType GetCustomerType(int customerTypeID)
        {
            var customerType = Exigo.OData().CustomerTypes
                               .Where(c => c.CustomerTypeID == customerTypeID)
                               .FirstOrDefault();

            if (customerType == null)
            {
                return(null);
            }

            return((CustomerType)customerType);
        }
示例#26
0
        public static CustomerStatus GetCustomerStatus(int customerStatusID)
        {
            var customerStatus = Exigo.OData().CustomerStatuses
                                 .Where(c => c.CustomerStatusID == customerStatusID)
                                 .FirstOrDefault();

            if (customerStatus == null)
            {
                return(null);
            }

            return((CustomerStatus)customerStatus);
        }
示例#27
0
        public static Customer GetCustomer(int customerID)
        {
            var customer = Exigo.OData().Customers.Expand("CustomerStatus,CustomerType,Rank,Enroller,Sponsor")
                           .Where(c => c.CustomerID == customerID)
                           .FirstOrDefault();

            if (customer == null)
            {
                return(null);
            }

            return((Customer)customer);
        }
        public static PointAccount GetPointAccount(int pointAccountID)
        {
            var pointAccount = Exigo.OData().PointAccounts
                               .Where(c => c.PointAccountID == pointAccountID)
                               .FirstOrDefault();

            if (pointAccount == null)
            {
                return(null);
            }

            return((ExigoService.PointAccount)pointAccount);
        }
示例#29
0
        public static IEnumerable <T> GetBinaryTree <T>(GetTreeRequest request) where T : ITreeNode
        {
            // Get the nodes
            var nodes           = new List <T>();
            var rowcount        = 50;
            var lastResultCount = rowcount;
            var callsMade       = 0;

            while (lastResultCount == rowcount)
            {
                var query = Exigo.OData().BinaryTree
                            .Where(c => c.TopCustomerID == request.TopCustomerID);

                // Filter by level
                var levels = (request.Levels != 0) ? request.Levels : 10;
                query = query.Where(c => c.Level <= levels);

                // Filter by legs
                if (request.Legs != 0)
                {
                    query = query.Where(c => c.Placement <= request.Legs);
                }

                // Get the data
                var results = query
                              .OrderBy(c => c.IndentedSort)
                              .Skip(callsMade * rowcount)
                              .Take(rowcount)
                              .Select(c => c)
                              .ToList();


                results.ForEach(c =>
                {
                    var node              = (T)Activator.CreateInstance(typeof(T));
                    node.CustomerID       = c.CustomerID;
                    node.ParentCustomerID = c.ParentID;
                    node.Level            = c.Level;
                    node.PlacementID      = c.Placement;
                    node.IndentedSort     = c.IndentedSort;
                    node.ChildNodeCount   = c.ChildCount;

                    nodes.Add(node);
                });

                callsMade++;
                lastResultCount = results.Count;
            }

            return(nodes);
        }
        public static CustomerPointAccount GetCustomerPointAccount(int customerID, int pointAccountID)
        {
            var pointAccount = Exigo.OData().CustomerPointAccounts.Expand("PointAccount")
                               .Where(c => c.CustomerID == customerID)
                               .Where(c => c.PointAccountID == pointAccountID)
                               .FirstOrDefault();

            if (pointAccount == null)
            {
                return(null);
            }

            return((ExigoService.CustomerPointAccount)pointAccount);
        }