public async Task <IActionResult> SetNotificationAsUnseen([FromRoute] string username, [FromRoute] string notificationCorrelationId) { CheckTokenIsValid(username); Username uName = new Username(username); NotificationCorrelationId correlationId = new NotificationCorrelationId(notificationCorrelationId); ChangeNotificationSeenStatusCommand changeNotificationSeenStatusCommand = new ChangeNotificationSeenStatusCommand(uName, correlationId, false); await _notificationService.ChangeNotificationSeenStatusAsync(changeNotificationSeenStatusCommand, CancellationToken.None); return(StatusCode((int)HttpStatusCode.OK)); }
public async Task ChangeNotificationSeenStatusAsync(ChangeNotificationSeenStatusCommand changeNotificationSeenStatusCommand, CancellationToken cancellationToken) { var notificationRepository = _repositoryFactory.Generate <INotificationRepository>(); Notification notification = await notificationRepository.GetNotificationAsync(changeNotificationSeenStatusCommand.Username, changeNotificationSeenStatusCommand.CorrelationId, cancellationToken); notification.ChangeSeenStatus(changeNotificationSeenStatusCommand.Seen); await notificationRepository.UpdateAsync(notification, cancellationToken); try { await _busControl.Publish(new NotificationSeenStatusChangedEvent(notification.CorrelationId.ToString(), notification.Username.ToString(), notification.Title.ToString(), notification.Content.ToString(), notification.OperationDate, notification.IsSeen), cancellationToken); } catch (Exception) { // Exception is swallowed } }