Beispiel #1
0
        public async Task <int> GetNotificationsCount(string userId, DateTime from, params int[] transportIds)
        {
            var nextSecond  = from.AddSeconds(1);
            var userCourses = await visitsRepo.GetUserCourses(userId);

            var deliveriesQueryable = db.NotificationDeliveries
                                      .Select(d => new { d.NotificationTransportId, d.Notification.CourseId, d.Notification.InitiatedById, d.CreateTime })
                                      .Where(d => transportIds.Contains(d.NotificationTransportId))
                                      .Where(d => userCourses.Contains(d.CourseId))
                                      .Where(d => d.InitiatedById != userId)
                                      .Where(d => d.CreateTime >= nextSecond);

            var totalCount = await deliveriesQueryable.CountAsync();

            return(totalCount);
        }
Beispiel #2
0
        private IQueryable <NotificationDelivery> GetFeedNotificationDeliveriesQueryable(string userId, params FeedNotificationTransport[] transports)
        {
            var transportsIds = new List <FeedNotificationTransport>(transports).Select(t => t.Id).ToList();
            var userCourses   = visitsRepo.GetUserCourses(userId);

            return(notificationsRepo.GetTransportsDeliveriesQueryable(transportsIds, DateTime.MinValue)
                   .Where(d => userCourses.Contains(d.Notification.CourseId))
                   .Where(d => d.Notification.InitiatedById != userId)

                   /* TODO (andgein): bad code. we need to make these navigation properties loading via Notification' interface */
                   .Include(d => (d.Notification as AbstractCommentNotification).Comment)
                   .Include(d => (d.Notification as CourseExportedToStepikNotification).Process)
                   .Include(d => (d.Notification as ReceivedCommentToCodeReviewNotification).Comment)
                   .Include(d => (d.Notification as PassedManualExerciseCheckingNotification).Checking)
                   .Include(d => (d.Notification as ReceivedCommentToCodeReviewNotification).Comment)
                   .Include(d => (d.Notification as AbstractPackageNotification).CourseVersion));
        }