Exemple #1
0
        public IActionResult Index()
        {
            var mergeRequests        = _context.MergeRequests.Where(r => r.SubmitAt < Now.AddDays(1).Date&& r.SubmitAt >= Now.Date).ToList();
            var mergeRequestsContent = _mergeRequestMailGenerator.GenerateMergeRequests(mergeRequests);
            var mailBody             = _mergeRequestMailGenerator.GenerateMailBody(mergeRequestsContent);

            var mail = new MergeRequestMail
            {
                Receiver = _mailConfig.Value.Receiver,
                Cc       = _mailConfig.Value.Cc,
                Subject  = string.Format(_mailConfig.Value.SubjectTemplate, Now),
                Content  = mailBody
            };

            return(View(mail));
        }
        public void SendTodayMergeRequestMail()
        {
            var mergeRequests = _context.MergeRequests.Where(r => r.SubmitAt < Now.AddDays(1).Date&& r.SubmitAt >= Now.Date).ToList();

            if (!mergeRequests.Any())
            {
                return;
            }

            var mergeRequestsContent = _mergeRequestMailGenerator.GenerateMergeRequests(mergeRequests);
            var mailBody             = _mergeRequestMailGenerator.GenerateMailBody(mergeRequestsContent);

            var mailSender = new MergeRequestMailSender(_mailServerConfig.Value);
            var mail       = new MergeRequestMail
            {
                Receiver  = _mailMessageConfig.Value.Receiver,
                Cc        = _mailMessageConfig.Value.Cc,
                Content   = mailBody,
                Subject   = string.Format(_mailMessageConfig.Value.SubjectTemplate, Now),
                TimeStamp = Now.ToString("MM/dd/yyyy")
            };

            mailSender.Send(mail);
        }