Exemplo n.º 1
0
        public JsonNetResult GetRecentActivity()
        {
            var customerID = Identity.Current.CustomerID;

            try
            {
                var recentActivities = Cache.Get("Dashboard_RecentActivity_{0}".FormatWith(customerID),
                                                 TimeSpan.FromMinutes(WidgetCacheTimeout),
                                                 () =>
                                                 Exigo.GetCustomerRecentActivity(new GetCustomerRecentActivityRequest
                {
                    CustomerID = customerID,
                    Page       = 1,
                    RowCount   = 50
                }).ToList()
                                                 );


                var html = this.RenderPartialViewToString("Cards/RecentActivity", recentActivities);

                return(new JsonNetResult(new
                {
                    success = true,
                    html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
Exemplo n.º 2
0
        public ActionResult Activity(int id)
        {
            var model = new List <CustomerWallItem>();

            model = Exigo.GetCustomerRecentActivity(new GetCustomerRecentActivityRequest
            {
                CustomerID = id
            }).OrderByDescending(c => c.EntryDate).ToList();

            return(PartialView("Partials/Activity", model));
        }
        public ActionResult Index(string token)
        {
            var model = new ProfileViewModel();
            var id    = Convert.ToInt32(Security.Decrypt(token, Identity.Current.CustomerID));

            if (id == 0)
            {
                id = Identity.Current.CustomerID;
            }

            model.Customer       = Exigo.GetCustomer(id);
            model.RecentActivity = Exigo.GetCustomerRecentActivity(new GetCustomerRecentActivityRequest
            {
                CustomerID = id
            });
            model.Volumes = Exigo.GetCustomerVolumes(new GetCustomerVolumesRequest
            {
                CustomerID   = id,
                PeriodTypeID = PeriodTypes.Default
            });



            if (Request.IsAjaxRequest())
            {
                try
                {
                    var customerTypeHtml = model.Customer.CustomerType.CustomerTypeDescription + " Details";
                    var html             = this.RenderPartialViewToString("Partials/_Profile", model);
                    return(new JsonNetResult(new
                    {
                        success = true,
                        html = html,
                        customertypehtml = customerTypeHtml
                    }));
                }
                catch (Exception e)
                {
                    return(new JsonNetResult(new
                    {
                        success = false,
                        message = e.Message
                    }));
                }
            }
            else
            {
                return(View(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));
        }