public UserNotification(UserNotificationInfo userNotification) : this( userNotification.UserId, userNotification.NotificationId, userNotification.State, userNotification.TenantId) { }
public virtual async Task InsertUserNotificationAsync(UserNotificationInfo userNotification) { using (_unitOfWorkManager.Current.SetTenantId(userNotification.TenantId)) { await _userNotificationRepository.InsertAsync(userNotification); await _unitOfWorkManager.Current.SaveChangesAsync(); } }
public IActionResult Add([FromBody] UserNotificationInfo item) { if (ModelState.IsValid) { var dbCompany = _userNotificationService.Add(item); return(Ok(dbCompany)); } return(BadRequest(ModelState)); }
public void InsertUserNotification(UserNotificationInfo userNotification) { //关闭多租户查询 using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant)) { _userNotificationInfoRepository.Insert(userNotification); _unitOfWorkManager.Current.SaveChanges(); } }
public IActionResult Update(Guid id, [FromBody] UserNotificationInfo item) { if (ModelState.IsValid) { _userNotificationService.Update(id, item); return(Ok(item)); } return(BadRequest(ModelState)); }
/// <summary> /// Converts <see cref="UserNotificationInfo"/> to <see cref="UserNotification"/>. /// </summary> public static UserNotification ToUserNotification(this UserNotificationInfo userNotificationInfo, Notification notification) { return(new UserNotification { Id = userNotificationInfo.Id, Notification = notification, UserId = userNotificationInfo.UserId, State = userNotificationInfo.State }); }
public virtual async Task InsertUserNotificationAsync(UserNotificationInfo userNotification) { //关闭多租户查询 using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant)) { await _userNotificationInfoRepository.InsertAsync(userNotification); await _unitOfWorkManager.Current.SaveChangesAsync(); } }
/// <summary> /// Converts <see cref="UserNotificationInfo"/> to <see cref="UserNotification"/>. /// 转换<see cref="UserNotificationInfo"/> 到 <see cref="UserNotification"/>. /// </summary> public static UserNotification ToUserNotification(this UserNotificationInfo userNotificationInfo, TenantNotification tenantNotification) { return(new UserNotification { Id = userNotificationInfo.Id, Notification = tenantNotification, UserId = userNotificationInfo.UserId, State = userNotificationInfo.State, TenantId = userNotificationInfo.TenantId }); }
public async Task ProcessAsync(UserNotificationInfo userNotificationsInfo) { if (userNotificationsInfo == null) { return; } var notification = await _notificationStore.GetNotificationOrNullAsync(userNotificationsInfo.NotificationId); if (notification == null) { return; } var firebaseNotificationData = FirebaseNotificationData.FromJsonString(notification.Data); firebaseNotificationData.Notification.Badge = (await _notificationStore.GetUserNotificationCountAsync(userNotificationsInfo.UserId, UserNotificationState.Unread)).ToString(); var firebaseRegistrations = await _firebaseService.GetAllRegistrationAsync(userNotificationsInfo.UserId); if (firebaseRegistrations.IsNullOrEmpty()) { return; } firebaseNotificationData.RegistrationIds.AddRange(firebaseRegistrations.Select(x => x.RegistrationId)); var json = firebaseNotificationData.ToString(); var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync(_configuration.Url, content); if (response.IsSuccessStatusCode) { await ProcessResponseOk(response, firebaseNotificationData); } else { await ProcessReponseError(response, firebaseNotificationData); } }
protected virtual async Task <List <UserNotification> > SaveUserNotificationsAsync(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); }
/// <summary> /// Initializes a new instance of the <see cref="UserNotificationInfoWithNotificationInfo"/> class. /// </summary> public UserNotificationInfoWithNotificationInfo(UserNotificationInfo userNotification, TenantNotificationInfo notification) { UserNotification = userNotification; Notification = notification; }
/// <summary> /// Initializes a new instance of the <see cref="UserNotificationInfoWithNotificationInfo"/> class. /// </summary> public UserNotificationInfoWithNotificationInfo(UserNotificationInfo userNotification, NotificationInfo notification) { UserNotification = userNotification; Notification = notification; }
/// <summary> /// Inserts a user notification. /// </summary> public async Task InsertUserNotificationAsync(UserNotificationInfo userNotification) { await _userNotificationRepository.InsertAsync(new UserNotification(userNotification)); }
/// <summary> /// Initializes a new instance of the <see cref="UserNotificationInfoWithNotificationInfo"/> class. /// </summary> public UserNotificationInfoWithNotificationInfo(UserNotificationInfo userNotification, TenantNotificationInfo notification) { this.UserNotification = userNotification; this.Notification = notification; }