Beispiel #1
0
        public JsonNetResult GetCurrentCommissions()
        {
            var customerID = Identity.Current.CustomerID;

            try
            {
                var currentCommissions = Cache.Get("Dashboard_CurrentCommissionsCard_{0}".FormatWith(customerID),
                                                   TimeSpan.FromMinutes(WidgetCacheTimeout),
                                                   () =>
                                                   Exigo.GetCustomerRealTimeCommissions(new GetCustomerRealTimeCommissionsRequest
                {
                    CustomerID       = customerID,
                    GetPeriodVolumes = true
                }).ToList()
                                                   );


                var html = this.RenderPartialViewToString("Cards/CurrentCommissions", currentCommissions);

                return(new JsonNetResult(new
                {
                    success = true,
                    html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
Beispiel #2
0
        public ActionResult CommissionDetail(int runid, int periodid)
        {
            var model = new CommissionDetailViewModel();

            // View Requests
            if (!Request.IsAjaxRequest())
            {
                model.CommissionPeriods = Exigo.GetCommissionPeriodList(Identity.Current.CustomerID, true);
                return(View("CommissionDetail", model));
            }

            // AJAX requests
            else
            {
                // Real-time commissions
                if (runid == 0)
                {
                    model.Commissions = Exigo.GetCustomerRealTimeCommissions(new GetCustomerRealTimeCommissionsRequest
                    {
                        CustomerID       = Identity.Current.CustomerID,
                        GetPeriodVolumes = true
                    });

                    // Check Period ID
                    if (periodid > 0)
                    {
                        model.PeriodID    = periodid;
                        model.Commissions = model.Commissions.Where(c => c.Period.PeriodID == periodid);
                    }

                    return(PartialView("_RealTimeCommissionDetail", model));
                }

                // Historical Commissions
                else
                {
                    model.Commissions = new List <ICommission>()
                    {
                        Exigo.GetCustomerHistoricalCommission(Identity.Current.CustomerID, runid)
                    };
                    return(PartialView("_HistoricalCommissionDetail", model));
                }
            }
        }
        public ActionResult CommissionDetail(int runid)
        {
            var model = new CommissionDetailViewModel();

            // View Requests
            if (!Request.IsAjaxRequest())
            {
                model.CommissionPeriods = Exigo.GetCommissionPeriodList(Identity.Current.CustomerID);
                return(View("CommissionDetail", model));
            }

            // AJAX requests
            else
            {
                // Real-time commissions
                if (runid == 0)
                {
                    model.Commissions = Exigo.GetCustomerRealTimeCommissions(new GetCustomerRealTimeCommissionsRequest
                    {
                        CustomerID = Identity.Current.CustomerID,
                        VolumeIDs  = new[] { 1, 2, 3, 4, 16 }
                    });
                    return(PartialView("_RealTimeCommissionDetail", model));
                }

                // Historical Commissions
                else
                {
                    model.Commissions = new List <ICommission>()
                    {
                        Exigo.GetCustomerHistoricalCommission(Identity.Current.CustomerID, runid)
                    };
                    return(PartialView("_HistoricalCommissionDetail", model));
                }
            }
        }
        public ActionResult Index()
        {
            var model      = new DashboardViewModel();
            var tasks      = new List <Task>();
            var customerID = Identity.Current.CustomerID;

            if (!GlobalSettings.Globalization.HideForLive)
            {
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    try
                    {
                        model.RecentOrders = Exigo.GetCustomerOrders(new GetCustomerOrdersRequest
                        {
                            CustomerID          = customerID,
                            IncludeOrderDetails = false,
                            Page     = 1,
                            RowCount = 4
                        }).ToList();
                    }
                    catch (Exception ex) { }
                }));
            }
            // Get the volumes
            tasks.Add(Task.Factory.StartNew(() =>
            {
                try
                {
                    model.Volumes = Exigo.GetCustomerVolumes(new GetCustomerVolumesRequest
                    {
                        CustomerID   = customerID,
                        PeriodTypeID = PeriodTypes.Default,
                        VolumeIDs    = new[] { 1, 2, 4, 16, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 91 }
                    });
                }
                catch (Exception ex) { }
            }));

            // Get the current commissions
            tasks.Add(Task.Factory.StartNew(() =>
            {
                try
                {
                    model.CurrentCommissions = Exigo.GetCustomerRealTimeCommissions(new GetCustomerRealTimeCommissionsRequest
                    {
                        CustomerID = customerID
                    }).ToList();
                }
                catch (Exception) { }
            }));

            // Get the customer's recent organization activity
            tasks.Add(Task.Factory.StartNew(() =>
            {
                try
                {
                    model.RecentActivities = Exigo.GetCustomerRecentActivity(new GetCustomerRecentActivityRequest
                    {
                        CustomerID = customerID,
                        Page       = 1,
                        RowCount   = 50
                    }).ToList();
                }
                catch (Exception ex) { }
            }));


            // Get the newest distributors
            tasks.Add(Task.Factory.StartNew(() =>
            {
                try
                {
                    model.NewestDistributors = Exigo.GetNewestDistributors(new GetNewestDistributorsRequest
                    {
                        CustomerID = customerID,
                        RowCount   = 12,
                        MaxLevel   = 99999
                    }).Where(c => c.CustomerID != customerID).ToList();
                }
                catch (Exception ex) { }
            }));


            // Perform all tasks
            Task.WaitAll(tasks.ToArray());
            tasks.Clear();

            return(View(model));
        }