public virtual async Task ChangeUserNotificationReadStateAsync(
            Guid?tenantId,
            Guid userId,
            long notificationId,
            NotificationReadState readState,
            CancellationToken cancellationToken = default)
        {
            using (var unitOfWork = _unitOfWorkManager.Begin())
                using (_currentTenant.Change(tenantId))
                {
                    var notification = await _userNotificationRepository.GetByIdAsync(userId, notificationId);

                    if (notification != null)
                    {
                        notification.ChangeReadState(readState);
                        await _userNotificationRepository.UpdateAsync(notification);

                        await unitOfWork.SaveChangesAsync();
                    }
                }
        }
Esempio n. 2
0
 public void ChangeReadState(NotificationReadState readStatus)
 {
     ReadStatus = readStatus;
 }
 public UserNotification(long notificationId, Guid userId)
 {
     UserId         = userId;
     NotificationId = notificationId;
     ReadStatus     = NotificationReadState.UnRead;
 }
        public virtual async Task <List <Notification> > GetNotificationsAsync(Guid userId, string filter = "", string sorting = "NotificationId", NotificationReadState readState = NotificationReadState.UnRead, int skipCount = 1, int maxResultCount = 10)
        {
            var userNofitications = await(from un in DbContext.Set <UserNotification>()
                                          join n in DbContext.Set <Notification>()
                                          on un.NotificationId equals n.NotificationId
                                          where un.UserId.Equals(userId) && un.ReadStatus.Equals(readState) &&
                                          (n.NotificationName.Contains(filter) || n.NotificationTypeName.Contains(filter) ||
                                           n.NotificationCateGory.Contains(filter))
                                          orderby sorting ?? nameof(Notification.NotificationId) descending
                                          select n)
                                    .Distinct()
                                    .Page(skipCount, maxResultCount)
                                    .AsNoTracking()
                                    .ToListAsync();

            return(userNofitications);
        }
        public virtual async Task <long> GetCountAsync(Guid userId, string filter = "", NotificationReadState readState = NotificationReadState.UnRead)
        {
            var userNofiticationCount = await(from un in DbContext.Set <UserNotification>()
                                              join n in DbContext.Set <Notification>()
                                              on un.NotificationId equals n.NotificationId
                                              where un.UserId.Equals(userId) && un.ReadStatus.Equals(readState) &&
                                              (n.NotificationName.Contains(filter) || n.NotificationTypeName.Contains(filter) ||
                                               n.NotificationCateGory.Contains(filter))
                                              select n)
                                        .Distinct()
                                        .LongCountAsync();

            return(userNofiticationCount);
        }
        public async Task ChangeUserNotificationReadStateAsync(Guid userId, long notificationId, NotificationReadState readState)
        {
            var userNofitication = await GetByIdAsync(userId, notificationId);

            userNofitication.ChangeReadState(readState);

            DbSet.Update(userNofitication);
        }
 public Task <List <NotificationInfo> > GetUserNotificationsAsync(Guid?tenantId, Guid userId, NotificationReadState readState = NotificationReadState.UnRead, int maxResultCount = 10)
 {
     return(Task.FromResult(new List <NotificationInfo>()));
 }
 public Task ChangeUserNotificationReadStateAsync(Guid?tenantId, Guid userId, long notificationId, NotificationReadState readState)
 {
     return(Task.CompletedTask);
 }
        public async Task ChangeUserNotificationReadStateAsync(Guid?tenantId, Guid userId, long notificationId, NotificationReadState readState)
        {
            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                using (CurrentTenant.Change(tenantId))
                {
                    await UserNotificationRepository.ChangeUserNotificationReadStateAsync(userId, notificationId, readState);

                    await unitOfWork.SaveChangesAsync();
                }
            }
        }
        public async Task <List <NotificationInfo> > GetUserNotificationsAsync(Guid?tenantId, Guid userId, NotificationReadState readState = NotificationReadState.UnRead, int maxResultCount = 10)
        {
            using (CurrentTenant.Change(tenantId))
            {
                var notifications = await UserNotificationRepository.GetNotificationsAsync(userId, readState, maxResultCount);

                return(_objectMapper.Map <List <Notification>, List <NotificationInfo> >(notifications));
            }
        }
Esempio n. 11
0
 public virtual async Task ChangeStateAsync(long id, NotificationReadState readState = NotificationReadState.Read)
 {
     await NotificationStore.ChangeUserNotificationReadStateAsync(CurrentTenant.Id, CurrentUser.GetId(), id, readState);
 }