internal async Task NoticeNewVersionAsync(string version) { var admins = await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin); var adminUids = admins.Select(a => a.Id).ToArray(); var notif = new NewVersionNotification { Version = version }; using (var db = _contextFactory.CreateContext()) { foreach (var uid in adminUids) { var data = notif.ToData(uid); db.Notifications.Add(data); } await db.SaveChangesAsync(); } // propagate notification _eventAggregator.Publish(new NotificationEvent { ApplicationUserIds = adminUids, Notification = notif }); }