Ejemplo n.º 1
0
 public static Task NotifyForNewComment(this ApplicationUser user, Post post, Comment comment)
 {
     return(Task.Factory.StartNew(() =>
     {
         using (var emailService = new Services.EmailService(new string[] { user.Email }))
         {
             emailService.SendToAllReceivers(string.Format(
                                                 "Your post '{0}' just got commented by {1}!",
                                                 post.Title,
                                                 comment.Owner.UserName));
         }
     }));
 }
Ejemplo n.º 2
0
        private Task NotifySubscribedUsersForNewPost()
        {
            var subscriberEmails = DbContext.Users.Where(u => u.IsSubscribedForNewPosts)
                                   .Select(u => u.Email)
                                   .ToList();

            return(Task.Factory.StartNew(() =>
            {
                if (subscriberEmails.Any())
                {
                    using (var service = new Service.EmailService(subscriberEmails))
                    {
                        service.SendToAllReceivers(string.Format("A new post has been uploaded to Xgag. Go check it out!"));
                    }
                }
            }));
        }