public async Task <IActionResult> Delete(int id) { int userId; try { userId = IdentityHelper.GetUserId(User); } catch (UnauthorizedAccessException) { return(Unauthorized()); } string deletedListName = await _listService.DeleteAsync(id, userId); // Notify var usersToBeNotified = await _userService.GetToBeNotifiedOfListDeletionAsync(id); if (usersToBeNotified.Any()) { var currentUser = await _userService.GetAsync(userId); foreach (var user in usersToBeNotified) { CultureInfo.CurrentCulture = new CultureInfo(user.Language, false); var message = _localizer["DeletedListNotification", IdentityHelper.GetUserName(User), deletedListName]; var createNotificationDto = new CreateOrUpdateNotification(user.Id, userId, null, null, message); var notificationId = await _notificationService.CreateOrUpdateAsync(createNotificationDto); var pushNotification = new PushNotification { SenderImageUri = currentUser.ImageUri, UserId = user.Id, Application = "To Do Assistant", Message = message, OpenUrl = GetNotificationsPageUrl(notificationId) }; _senderService.Enqueue(pushNotification); } } return(NoContent()); }