Ejemplo n.º 1
0
        public FeedController(ULearnDb db, CourseManager courseManager)
        {
            this.db            = db;
            this.courseManager = courseManager;
            feedRepo           = new FeedRepo(db);

            if (commonFeedNotificationTransport == null)
            {
                commonFeedNotificationTransport = feedRepo.GetCommonFeedNotificationTransport();
            }
        }
Ejemplo n.º 2
0
        public NotificationsController(ILogger logger, WebCourseManager courseManager, UlearnDb db, NotificationsRepo notificationsRepo, FeedRepo feedRepo, NotificationDataPreloader notificationDataPreloader)
            : base(logger, courseManager, db)
        {
            this.notificationsRepo         = notificationsRepo ?? throw new ArgumentNullException(nameof(notificationsRepo));
            this.feedRepo                  = feedRepo ?? throw new ArgumentNullException(nameof(feedRepo));
            this.notificationDataPreloader = notificationDataPreloader;

            if (commentsFeedNotificationTransport == null)
            {
                commentsFeedNotificationTransport = feedRepo.GetCommentsFeedNotificationTransport();
            }
        }
Ejemplo n.º 3
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            if (commentsFeedNotificationTransport == null)
            {
                commentsFeedNotificationTransport = await feedRepo.GetCommentsFeedNotificationTransport();
            }

            var userId = User.GetUserId();
            await feedRepo.AddFeedNotificationTransportIfNeeded(userId);

            await next();
        }
Ejemplo n.º 4
0
        private async Task <Tuple <int, DateTime?> > GetUnreadNotificationsCountAndLastTimestampAsync(string userId, FeedNotificationTransport transport, DateTime?from = null)
        {
            var realFrom = from ?? await feedRepo.GetFeedViewTimestampAsync(userId, transport.Id).ConfigureAwait(false) ?? DateTime.MinValue;

            var unreadCount = await feedRepo.GetNotificationsCountAsync(userId, realFrom, transport).ConfigureAwait(false);

            if (unreadCount > 0)
            {
                from = await feedRepo.GetLastDeliveryTimestampAsync(transport).ConfigureAwait(false);
            }

            return(Tuple.Create(unreadCount, from));
        }
Ejemplo n.º 5
0
 public DateTime?GetLastDeliveryTimestamp(FeedNotificationTransport notificationTransport)
 {
     return(notificationsRepo.GetLastDeliveryTimestamp(notificationTransport));
 }
Ejemplo n.º 6
0
        private Tuple <int, DateTime?> GetUnreadNotificationsCountAndLastTimestamp(string userId, FeedNotificationTransport transport, DateTime?from = null)
        {
            var realFrom    = from ?? feedRepo.GetFeedViewTimestamp(userId, transport.Id) ?? DateTime.MinValue;
            var unreadCount = feedRepo.GetNotificationsCount(userId, realFrom, transport);

            if (unreadCount > 0)
            {
                from = feedRepo.GetLastDeliveryTimestamp(transport);
            }

            return(Tuple.Create(unreadCount, from));
        }
Ejemplo n.º 7
0
 public async Task <DateTime?> GetLastDeliveryTimestampAsync(FeedNotificationTransport notificationTransport)
 {
     return(await notificationsRepo.GetLastDeliveryTimestampAsync(notificationTransport));
 }