Exemplo n.º 1
0
        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", "");
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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", "");
        }