Пример #1
0
        private List <DashboardSaleBoxToken> getDashboardSaleStats(DateRangeToken dates, int userId, short currencyId, int?storeId)
        {
            try
            {
                using (var context = new lfeAuthorEntities())
                {
                    var stats = context.tvf_DB_GetAuthorSalesStats(dates.from, dates.to, userId, currencyId, storeId).FirstOrDefault();

                    if (stats == null)
                    {
                        return(EmptySalesBoxesList);
                    }

                    var list = new List <DashboardSaleBoxToken>
                    {
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.ONE_TIME, stats.AuthorTotalOnetimeSales, stats.AuthorTotalOnetimeQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.SUBSCRIPTION, stats.AuthorTotalSubscriptionSales, stats.AuthorTotalSubscriptionQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.RENTAL, stats.AuthorTotalRentalSales, stats.AuthorTotalRentalQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.SALES_BY_AFFILIATES, stats.ByAffiliateTotalSales, stats.ByAffiliateTotalQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.AFFILIATE_SALES, stats.AffiliateTotalSales, stats.AffiliateTotalQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.SUBSCRIPTION_CANCELLATION, stats.TotalCancelled, stats.TotalCancelledQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.REFUNDS, stats.TotalRefund, stats.TotalRefundQty),
                        new DashboardSaleBoxToken(DashboardEnums.eSaleBoxType.COUPONS_USED, stats.TotalCouponValue, stats.TotalCouponQty)
                    };

                    return(list);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("getDashboardSaleStats", ex, CommonEnums.LoggerObjectTypes.Dashboard);
                return(EmptySalesBoxesList);
            }
        }
Пример #2
0
 public List <DashboardEventToken> GetDashboardEvents(int userId, DateRangeToken dates)
 {
     try
     {
         return(new List <DashboardEventToken>
         {
             GetDashboardEventToken(userId, DashboardEnums.eDbEventTypes.NewItem, dates),
             GetDashboardEventToken(userId, DashboardEnums.eDbEventTypes.NewChapter, dates),
             GetDashboardEventToken(userId, DashboardEnums.eDbEventTypes.NewFbStore, dates),
             GetDashboardEventToken(userId, DashboardEnums.eDbEventTypes.NewStore, dates),
             GetDashboardEventToken(userId, DashboardEnums.eDbEventTypes.NewMailchimp, dates)
         });
     }
     catch (Exception ex)
     {
         Logger.Error("GetDashboardEvents", ex, CommonEnums.LoggerObjectTypes.Author);
         return(new List <DashboardEventToken>());
     }
 }
Пример #3
0
        public DashboardEventToken GetDashboardEventToken(int userId, DashboardEnums.eDbEventTypes type, DateRangeToken dates, string eventName = null)
        {
            var token = new DashboardEventToken
            {
                Uid        = Guid.NewGuid()
                , Type     = type
                , Name     = eventName ?? Utils.GetEnumDescription(type)
                , Color    = type.EventType2Color()
                , Enabled  = true
                , IsStatic = false
            };

            if (type == DashboardEnums.eDbEventTypes.Custom || type == DashboardEnums.eDbEventTypes.NewMailchimp)
            {
                return(token);
            }

            token.IsStatic = true;

            using (var context = new lfeAuthorEntities())
            {
                var evenStats = context.tvf_DB_GetAuthorEventStats(userId).FirstOrDefault();

                if (evenStats == null)
                {
                    return(token);
                }

                DateTime?date = null;

                switch (type)
                {
                case DashboardEnums.eDbEventTypes.NewItem:
                    var cd = evenStats.LastCoursePublish;
                    var bd = evenStats.LastBundlePublish;

                    if (cd == null && bd == null)
                    {
                        return(token);
                    }

                    date = (cd ?? DateTime.MinValue).CompareToDate(bd ?? DateTime.MinValue);
                    break;

                case DashboardEnums.eDbEventTypes.NewChapter:
                    date = evenStats.LastChaperCreated;
                    break;

                case DashboardEnums.eDbEventTypes.NewFbStore:
                    date = evenStats.LastChaperCreated;
                    break;

                case DashboardEnums.eDbEventTypes.NewStore:
                    date = evenStats.LastChaperCreated;
                    break;
                }

                token.Date    = date;
                token.Enabled = date != null && (((DateTime)date).Ticks >= dates.from.Ticks && ((DateTime)date).Ticks <= dates.to.Ticks);

                return(token);
            }
        }
Пример #4
0
        public ActionResult GetDashboardEventsList([DataSourceRequest] DataSourceRequest request, int userId, DateRangeToken dates)
        {
            var list = _dashboardServices.GetDashboardEvents(userId, dates);

            return(Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }