public static void PushNotification(string title, string content, UserRole role) { var usersRepository = new RepositoryFactory().GetUsersRepository(); var usersToNotification = usersRepository.Where(user => ((UserRole) user.RoleId).HasFlag(role)); foreach (var user in usersToNotification) { PushNotification(title, content, user.Id); } }
public static void PushNotification(string title, string content, int userId) { var notification = new Notification() { Title = title, Content = content, IsDelivered = false, UserId = userId, TimeEdit = DateTime.UtcNow }; using (new UnitOfWork(EntitiesContext.Current)) { var notificationsRepository = new RepositoryFactory().GetNotificationsRepository(); notificationsRepository.Add(notification); } }