public async Task <bool> SendTopicReplyEmailNotificationAsync(int topicId, string currentUserId, string url)
        {
            try
            {
                var topic = await _manageForumTopics.GetForumTopicAsync(topicId);

                var currentUser = await _manageUsers.GetUserAsync(currentUserId);

                var topicSubscriptions = await _manageTopicSubscriptions.GetSubscriptionsForTopicAsync(topicId);

                foreach (var subscription in topicSubscriptions.Where(p => p.Id != currentUser.Id).ToList())
                {
                    var user = await _manageUsers.GetUserAsync(subscription.Id);

                    await _emailSender.SendEmailAsync(user.Email, "RE: " + topic.Title, currentUser.UserName + " has posted a reply to a topic that you're subscribed to at: <a href=\"" + url + "\">" + url + "</a>.");
                }

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "There was a problem emailing the topic reply notification(s)");

                return(false);
            }
        }
Пример #2
0
        public async Task <bool> CurrentUserIsSubscribedToTopic(string currentUserId, int topicId)
        {
            if (currentUserId != null)
            {
                var subscriptions = await _manageTopicSubscriptions.GetSubscriptionsForTopicAsync(topicId);

                var subscription = subscriptions.Where(p => p.Id == currentUserId).FirstOrDefault();
                return(subscription == null ? false : true);
            }
            return(false);
        }
Пример #3
0
        public async Task SendTopicReplyEmailNotification(int topicId, string currentUserId, string url)
        {
            var topic = await _manageForumTopics.GetForumTopicAsync(topicId);

            var currentUser = await _userManager.FindByIdAsync(currentUserId);

            var topicSubscriptions = await _manageTopicSubscriptions.GetSubscriptionsForTopicAsync(topicId);

            foreach (var subscription in topicSubscriptions.Where(p => p.Id != currentUser.Id).ToList())
            {
                var user = await _userManager.FindByIdAsync(subscription.Id);

                await _emailSender.SendEmailAsync(user.Email, "RE: " + topic.Title, currentUser.UserName + " has posted a reply to a topic that you're subscribed to at: <a href=\"" + url + "\">" + url + "</a>.");
            }
        }