Exemplo n.º 1
0
        public List <DbSubscriptionDetailToken> GetActiveSubscribers(int userId)
        {
            try
            {
                var result = OrderLinesViewRepository.GetMany(x => x.SellerUserId == userId && x.LineTypeId == (byte)BillingEnums.eOrderLineTypes.SUBSCRIPTION && x.OrderStatusId == (byte)BillingEnums.eOrderStatuses.ACTIVE).ToList();
                var lines  = result.Select(x => x.Entity2DbSubscriptionDetailToken()).OrderByDescending(x => x.OrderNumber).ToList();

                return(lines);
            }
            catch (Exception ex)
            {
                Logger.Error("GetActiveSubscribers", ex, CommonEnums.LoggerObjectTypes.Dashboard);

                return(new List <DbSubscriptionDetailToken>());
            }
        }
Exemplo n.º 2
0
 public DashboardStatsToken GetAuthorDashboardStats(int userId)
 {
     try
     {
         var dto = new DashboardStatsToken
         {
             Courses            = CourseRepository.Count(c => c.AuthorUserId == userId),
             UnpublishedCourses = CourseRepository.Count(c => c.AuthorUserId == userId && c.StatusId == (short)CourseEnums.CourseStatus.Draft),
             Bundles            = BundleRepository.Count(c => c.AuthorId == userId),
             Stores             = _GetOwnerStores(userId).Count(),
             ActiveSubscribers  = OrderLinesViewRepository.Count(x => x.SellerUserId == userId && x.LineTypeId == (byte)BillingEnums.eOrderLineTypes.SUBSCRIPTION && x.OrderStatusId == (byte)BillingEnums.eOrderStatuses.ACTIVE)
         };
         return(dto);
     }
     catch (Exception ex)
     {
         Logger.Error("get course statistic for dashboard", userId, ex, CommonEnums.LoggerObjectTypes.Dashboard);
         return(new DashboardStatsToken());
     }
 }
Exemplo n.º 3
0
        public void FixBundleCourseAccessProblem(out string emails)
        {
            emails = string.Empty;
            var from            = DateTime.Now.AddDays(-3);
            var bundlePurchases = OrderLinesViewRepository.GetMany(x => x.BundleId != null && x.OrderDate > from).OrderByDescending(x => x.OrderDate).ToList();

            foreach (var orderLine in bundlePurchases)
            {
                var line          = orderLine;
                var bundleCourses = BundleCourseRepository.Count(x => x.BundleId == line.BundleId);
                var userCourses   = UserCourseRepository.Count(x => x.UserId == line.BuyerUserId && x.OrderLineId == line.LineId);

                if (bundleCourses == userCourses)
                {
                    continue;
                }

                string error;
                AttachCourseOrBundle2User(line.BuyerUserId, line.LineId, null, line.BundleId, null, out error);
                emails += String.Format("{0}-{1}-{2}-{3}-{4},", line.BuyerEmail, line.SellerFirstName + " " + line.SellerLastName, line.OrderDate, bundleCourses, userCourses);
            }
        }