public List <TotalsBoxToken> GetTotals(ReportEnums.ePeriodSelectionKinds period)
        {
            try
            {
                var reportPeriod = PeriodSelection2DateRange(period);

                var previousPeriod = Period2Previous(period);

                using (var context = new lfeAuthorEntities())
                {
                    var totals = context.tvf_FACT_DASH_GetTotals().FirstOrDefault();

                    if (totals == null)
                    {
                        return(new List <TotalsBoxToken>());
                    }

                    var rows         = context.tvf_FACT_DASH_GetNewPeriodTotals(reportPeriod.from, reportPeriod.to).ToList();
                    var previousRows = context.tvf_FACT_DASH_GetNewPeriodTotals(previousPeriod.from, previousPeriod.to).ToList();

                    var list = new List <TotalsBoxToken>
                    {
                        ReportEnums.eStatsTypes.Stores.Type2TotalsBoxToken(1, totals.TotalStores, rows.Sum(x => x.NewStores), previousRows.Sum(x => x.NewStores)),
                        ReportEnums.eStatsTypes.Courses.Type2TotalsBoxToken(2, totals.TotalCourses, rows.Sum(x => x.NewCourses), previousRows.Sum(x => x.NewCourses)),
                        ReportEnums.eStatsTypes.Bundles.Type2TotalsBoxToken(3, totals.TotalBundles, rows.Sum(x => x.NewBundles), previousRows.Sum(x => x.NewBundles)),
                        ReportEnums.eStatsTypes.Learners.Type2TotalsBoxToken(4, totals.TotalLearners, rows.Sum(x => x.NewLearners), previousRows.Sum(x => x.NewLearners)),
                        ReportEnums.eStatsTypes.Authors.Type2TotalsBoxToken(5, totals.TotalAuthors, rows.Sum(x => x.NewAuthors), previousRows.Sum(x => x.NewAuthors))
                    };

                    return(list);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Get totals stats for admin dashboard", ex, CommonEnums.LoggerObjectTypes.Reports);
                return(new List <TotalsBoxToken>());
            }
        }
        public IntegrationStatsToken GetIntegrationStatsToken(ReportEnums.ePeriodSelectionKinds period)
        {
            try
            {
                var reportPeriod = PeriodSelection2DateRange(period);

                using (var context = new lfeAuthorEntities())
                {
                    var rows = context.tvf_FACT_DASH_GetNewPeriodTotals(reportPeriod.from, reportPeriod.to).ToList();

                    return(new IntegrationStatsToken
                    {
                        TotalMailchimp = rows.Sum(x => x.NewMailchimpLists)
                        , MbgJoined = rows.Sum(x => x.NewMBGJoined)
                        , MbgCanceled = rows.Sum(x => x.MBGCancelled)
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Get Admin Dashboard integration stats", ex, CommonEnums.LoggerObjectTypes.Reports);
                return(new IntegrationStatsToken());
            }
        }