public async Task Post([FromBody] dynamic data) { if (data == null || data.Acknowledgment == null || data.broadcastMode == null || data.Message == null || data.UserId == null || data.NotificationType == null) { _logger.Log(LogLevel.Warn, "InAppNotificationAdminController", "Notification is not valid", new { data }); return; } var notif = new InAppNotification { Acknowledgment = data.Acknowledgment, NotificationType = data.NotificationType, Message = data.Message, UserId = data.UserId, CreatedOn = DateTime.UtcNow, Type = "notification.admin" }; var broadcastMode = (BroadcastMode)(data.BroadcastMode ?? BroadcastMode.None); if (broadcastMode == BroadcastMode.AllConnectedUsers) { // TODO await _notificationChannel.SendNotification("AdminNotificationBroadcastAllConnectedUsers", notif); } else if (broadcastMode == BroadcastMode.AllUsers) { // TODO //await _notificationChannel.SendNotification("AdminNotificationBroadcastAllUsers", notif); } else //if (broadcastMode == BroadcastMode.None) { var record = new InAppNotificationRecord(notif); await _repository.IndexNotification(record); // TODO await _notificationChannel.SendNotification("AdminNotification.ByUserId", notif); } }
public Task <bool> SendNotification(string type, InAppNotification data) { return(channel.SendNotification(type, data)); }