public void AssignCourseCancelledNotification(CourseCancelledNotification notification, out Dictionary <string, List <int> > affectedUsersIds) { affectedUsersIds = new Dictionary <string, List <int> >(); if (notification != null) { var attenderNotifications = ( from attender in _context.CoursesAttenders where attender.CourseId == notification.CourseId select attender.AttenderId ).ToList <string>().Distinct().Select(id => new UserNotification(notification.Id, id)); if (attenderNotifications != null && attenderNotifications.Count() > 0) { _context.UserNotifications.AddRange(attenderNotifications); foreach (UserNotification un in attenderNotifications) { if (!affectedUsersIds.ContainsKey(un.UserId)) { affectedUsersIds.Add(un.UserId, new List <int>()); } affectedUsersIds[un.UserId].Add(un.NotificationId); } } } }
private void CoursesAntenna_CourseCancelled(Course course) { CourseCancelledNotification notification = unitOfWork.NotificationsRepository.AddCourseCancelledNotification(course, ContextHelpers.CurrentLoggedInUser.Id); unitOfWork.Complete(); Dictionary <string, List <int> > affectedUsersIds = null; unitOfWork.NotificationsRepository.AssignCourseCancelledNotification(notification, out affectedUsersIds); unitOfWork.Complete(); if (affectedUsersIds != null && affectedUsersIds.Count > 0) { NotifyUsers(affectedUsersIds); } }