public async Task <ActionResult <List <NotificationDto> > > GetNotifications() { var userName = _httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; var userFromRepo = await _userRepository.GetAsync(u => u.UserName == userName); if (userFromRepo == null) { throw new KeyNotFoundException("Unable to locate user"); } var query = new NotificationsQuery(userFromRepo.Id); _logger.LogInformation( "----- Sending query: NotificationsQuery - {userId}", userFromRepo.Id); var queryResult = await _mediator.Send(query); if (queryResult == null) { return(BadRequest("Query not created")); } return(Ok(queryResult)); //if (await _userManager.IsInRoleAsync(userFromManager, Constants.Role.Clinician)) //{ // notifications.AddRange(PrepareNotificationsForClinician(compareDate)); //} //if (await _userManager.IsInRoleAsync(userFromManager, Constants.Role.PVSpecialist)) //{ // notifications.AddRange(PrepareNotificationsForAnalyst(compareDate)); //} }
public async Task Should_Read_All_Notifications() { NotificationModel[] result; User sender = new User((Nickname)"sender", (FullName)"sender user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio"); User recipient = new User((Nickname)"recipient", (FullName)"recipient user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio"); var not1 = new Notification(sender, recipient, "Notification 1"); var not2 = new Notification(sender, recipient, "Notification 2"); var not3 = new Notification(sender, recipient, "Notification 3"); using (var session = _testFixture.OpenSession(_output)) { not1.MarkAsRead(); await session.SaveAsync(sender); await session.SaveAsync(recipient); await session.SaveAsync(not1); await session.SaveAsync(not2); await session.SaveAsync(not3); await session.FlushAsync(); } var query = new NotificationsQuery(recipient.ID, true); using (var session = _testFixture.OpenSession(_output)) { var sut = new NotificationsQueryHandler(session, Log.Logger); result = await sut.Handle(query, default); } result.Count().Should().Be(3); }
protected override IEnumerable <WebApiServiceHookNotification> DoGetItems() { var subscription = GetItem <WebApiSubscription>(); var client = GetClient <ServiceHooksPublisherHttpClient>(); var from = GetParameter <DateTime?>(nameof(GetServiceHookNotificationHistory.From)); var to = GetParameter <DateTime?>(nameof(GetServiceHookNotificationHistory.To)); var status = GetParameter <NotificationStatus?>(nameof(GetServiceHookNotificationHistory.Status)); var query = new NotificationsQuery() { SubscriptionIds = new[] { subscription.Id }, MinCreatedDate = from, MaxCreatedDate = to, Status = status }; var result = client.QueryNotificationsAsync(query) .GetResult("Error getting service hook notifications") .Results; foreach (var r in result) { yield return(r); } }
void ShowNotificationCenterViewWithoutHandlers() { var query = NotificationsQuery.WithAllStatuses(); NotificationCenterViewBuilder.Create(query) .SetViewStateCallbacks(() => _console.LogD("Notifications view opened"), () => _console.LogD("Notifications view closed")) .Show(); }
public async Task <IActionResult> Index() { // Loads all unread notifications var query = new NotificationsQuery(User.GetIdentifier(), false); var notifications = await _dispatcher.Send(query); // Marks all unread notifications as read var markAllAsReadCommand = new MarkAllUserNotificationsReadCommand(User.GetIdentifier()); await _dispatcher.Send(markAllAsReadCommand); return(View(notifications)); }
private NotificationsQuery CreateQuery() { var query = NotificationsQuery.WithStatuses(Filters.Where((t, i) => _selectedFilters[i]).ToArray()); if (_likedAndComments) { query.OfTypes(Notification.NotificationTypes.Comment, Notification.NotificationTypes.LikeActivity, Notification.NotificationTypes.LikeComment); } if (_actions.Count > 0) { query.WithActions(_actions.ConvertAll(it => it.ActionId).ToArray()); } return(query); }
void ShowNotificationCenterView() { var query = NotificationsQuery.WithAllStatuses(); var notificationCenterView = NotificationCenterViewBuilder.Create(query); notificationCenterView .SetNotificationClickListener((notification, context) => { _console.LogD("Notification click listener invoked: " + notification.Id); if (context != null && context.Action != null) { demoController.HandleAction(notification.Action); _console.LogD("Action button listener invoked: " + context.Action + " - " + notification.Id); } }) .SetViewStateCallbacks(() => _console.LogD("Notifications view opened"), () => _console.LogD("Notifications view closed")) .Show(); }
private void UpdateNotificationsWindow() { InitUiElements(-1, false); _showLoading.Raise(); var query = NotificationsQuery.ReadAndUnread().OfTypes( Notification.NotificationTypes.Comment, Notification.NotificationTypes.Direct, Notification.NotificationTypes.MentionInActivity, Notification.NotificationTypes.MentionInComment, Notification.NotificationTypes.ReplyToComment, Notification.NotificationTypes.Targeting); GetSocial.User.GetNotifications(query, onSuccess: notifications => { // var notifications = new List<Notification>(); // for (int i = 0; i < 20; i++) // { // notifications.Add(NewItem("Title " + i, "text")); // } var notificaiotnsToShow = notifications.FindAll(notification => !_clearedNotifications.Contains(notification.Id)); _notifications.Clear(); _notifications.UnionWith(notificaiotnsToShow.Select(notification => notification.Id)); _dismissLoading.Raise(); InitUiElements(notificaiotnsToShow.Count, false); PopulateList(notificaiotnsToShow); }, onError: error => { Debug.LogError(error.Message); _dismissLoading.Raise(); InitUiElements(0, true); }); }
internal NotificationCenterViewBuilder(NotificationsQuery query) { _query = query; }
#pragma warning restore 414 public static NotificationCenterViewBuilder Create(NotificationsQuery query) { return(new NotificationCenterViewBuilder(query)); }