Пример #1
0
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                var projects = await _db.Projects.Where(p => p.Status == Project.ProjectStatusEnum.Ongoing)
                               .ToListAsync();

                foreach (var mailer in from project in projects where project != null
                         let body = HelperMethod.ProjectPrepareTemplate(project)
                                    select new Email {
                    ToEmail = project.ApplicationUser.Email,
                    Subject = "Keep Track On your Cause",
                    Body = body,
                    IsHtml = true
                })
                {
                    mailer.Send();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                Console.WriteLine(e);
            }
        }
Пример #2
0
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                var followList = await _db.Follows.Where(f =>
                                                         f.Status == Follow.FollowStatusEnum.Followed &&
                                                         f.Project.Status == Project.ProjectStatusEnum.Ongoing).ToListAsync();

                foreach (var project in followList.Select(item => item.Project))
                {
                    if (project == null)
                    {
                        continue;
                    }
                    var body = HelperMethod.ProjectPrepareTemplate(project);

                    var mailer = new Email
                    {
                        ToEmail = "*****@*****.**",
                        Subject = "Keep Track On Our Cause",
                        Body    = body,
                        IsHtml  = true
                    };
                    mailer.Send();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                Console.WriteLine(e);
            }
        }