protected void AddNotification(String text, ArticleHistory history, Boolean includeAdmins, params Int32[] recipientIds) { if (includeAdmins) { recipientIds = dbContext.User.Where(u => u.Status == UserStatus.ADMINISTRATOR) .Select(u => u.Id).Union(recipientIds).ToArray(); } var curUserId = GetCurrentUserId(); List <UserNotification> notifications = new List <UserNotification>(); foreach (var recipientId in recipientIds.Distinct()) { if (recipientId != curUserId) { var notification = new UserNotification(); notification.Text = text; notification.RecipientId = recipientId; notification.InsertDate = DateTime.Now; notification.ArticleHistory = history; notifications.Add(notification); } } dbContext.UserNotification.AddRange(notifications); senderHub.AddNotifications(notifications); }