public async Task InvokeAsync() { var allBDList = AssociateQueryServices.GetUpcomingAssociateBirthdays(); if (allBDList != null && allBDList.Count > 0) { var associates = AssociateQueryServices.GetAssociateEmailList(); var subject = AssociateQueryServices.GetValue("BirthdayReminder_Subject"); foreach (var asc in associates) { var bdList = allBDList.Where(x => x.AssociateId != asc.AssociateId).ToList(); if (bdList != null && bdList.Count > 0) { var data = string.Join(", ", bdList.Select(x => x.AssociateName).ToList()); await NotificationServices.SendEmail(new Models.BirthdayReminderNotificationModel { To = asc.AssociateEmail, Subject = $"{subject} ({DateTime.UtcNow.AddDays(1).Date.ToShortDateString()})", Template = AssociateQueryServices.GetValue("BirthdayReminderTemplate"), Associates = data }); } } await NotificationServices.NotifyOnSlackChannel(AssociateQueryServices.GetValue("BirthDayReminderMessage")); } }
public async Task InvokeAsync() { var birthdayList = AssociateQueryServices.GetBirthdayPersonList(); foreach (var bd in birthdayList) { var msgList = AssociateQueryServices.GetBirthdayWishesByAssociateId(bd.AssociateId); var msg = ""; if (msgList.Count > 0) { msg = "<h4>We have a surprise birthday wishes for you</h4> <br/>"; msgList.ForEach(m => { msg += $"<span>{m.Message}</span><br/> <span>-{m.SenderName}</span><br/><br/>"; }); } else { msg = "We Wish you a year Full of Minutes of Love and Happiness"; } await NotificationServices.SendEmail(new Models.BirthdayNotificationModel { To = bd.AssociateEmail, Subject = $"Happy Birthday {bd.AssociateName}", Template = AssociateQueryServices.GetValue("BirthdayTemplate"), Message = msg, AssociateName = bd.AssociateName }); await NotificationServices.NotifyUser(bd.AssociateEmail, msgList); } }