public async Task CreateAsync(Notificare notificare, int clientId) { _context.Notificari.Add(notificare); _context.SaveChanges(); var users = _context.ApplicationUsers .Include(x => x.Client) .Where(x => x.ClientId == clientId) .ToList(); foreach (var user in users) { var notificareUser = new NotificareUser() { }; notificareUser.ApplicationUserId = user.Id; notificareUser.NotificareId = notificare.NotificareId; _context.NotificareUsers.Add(notificareUser); } _context.SaveChanges(); // execute client side method from site.js await _hubContext.Clients.All.SendAsync("displayNotification", ""); }
public void CreateNotificationQuestionsByAdmin(Notificare notificare, List <ApplicationUser> users) { _context.Notificari.Add(notificare); _context.SaveChanges(); foreach (var user in users) { var notificareUser = new NotificareUser() { }; notificareUser.ApplicationUserId = user.Id; notificareUser.NotificareId = notificare.NotificareId; _context.NotificareUsers.Add(notificareUser); } _context.SaveChanges(); }
public async Task CreateChatNotificationAsync(Notificare notificare, string userId) { _context.Notificari.Add(notificare); _context.SaveChanges(); var notificareUser = new NotificareUser() { }; notificareUser.ApplicationUserId = userId; notificareUser.NotificareId = notificare.NotificareId; _context.NotificareUsers.Add(notificareUser); _context.SaveChanges(); // execute client side method from site.js await _hubContext.Clients.All.SendAsync("displayNotification", ""); }