private IEnumerable <string> GetRecipients(NotificationDataModel notificationDataModel) { return(ConnectedUsers.Where( user => user.Value != currentUserId && // not the person who is notifying right now (notificationDataModel.PassengersIds.Exists(passenger => passenger == user.Value) || // passengers user.Value == notificationDataModel.Trip.DriverId)// driver ).Select(user => user.Key.ToString())); }
public async Task DeclineTripNotif(int tripId) { NotificationDataModel notificationDataModel = await GetNotificationDataModel(tripId); var Recipients = GetRecipients(notificationDataModel).ToList().AsReadOnly(); await Clients.Clients(Recipients).SendAsync("declineTrip", new NotificationPayloadModel { Id = ++FakeID, FullName = notificationDataModel.CurrentUser.FullName, Destination = notificationDataModel.Trip.Destination }); }