Пример #1
0
        public virtual async Task InsertUserNotificationAsync(UserNotificationInfo userNotification)
        {
            using (unitOfWorkManager.Current.SetTenantId(userNotification.TenantId))
            {
                await userNotificationRepository.InsertAsync(userNotification);

                await unitOfWorkManager.Current.SaveChangesAsync();
            }
        }
Пример #2
0
        protected virtual async Task <List <UserNotification> > SaveUserNotifications(UserIdentifier[] users,
                                                                                      NotificationInfo notificationInfo)
        {
            var userNotifications = new List <UserNotification>();

            var tenantGroups = users.GroupBy(user => user.TenantId);

            foreach (var tenantGroup in tenantGroups)
            {
                using (unitOfWorkManager.Current.SetTenantId(tenantGroup.Key))
                {
                    var tenantNotificationInfo = new TenantNotificationInfo(guidGenerator.Create(), tenantGroup.Key,
                                                                            notificationInfo);
                    await notificationStore.InsertTenantNotificationAsync(tenantNotificationInfo);

                    await unitOfWorkManager.Current.SaveChangesAsync(); //To get tenantNotification.Id.

                    var tenantNotification = tenantNotificationInfo.ToTenantNotification();

                    foreach (var user in tenantGroup)
                    {
                        var userNotification = new UserNotificationInfo(guidGenerator.Create())
                        {
                            TenantId             = tenantGroup.Key,
                            UserId               = user.UserId,
                            TenantNotificationId = tenantNotificationInfo.Id
                        };

                        await notificationStore.InsertUserNotificationAsync(userNotification);

                        userNotifications.Add(userNotification.ToUserNotification(tenantNotification));
                    }

                    await CurrentUnitOfWork.SaveChangesAsync(); //To get Ids of the notifications
                }
            }

            return(userNotifications);
        }
Пример #3
0
 public Task InsertUserNotificationAsync(UserNotificationInfo userNotification)
 {
     return(Task.FromResult(0));
 }