コード例 #1
0
        public bool SendReminders(List <string> userIds, int reminderId)
        {
            var myUser   = _unitOfWork.UserRepository.GetAll().ToList();
            var userList = myUser.Where(m => userIds.Where(z => ObjectId.Parse(z) == m.Id).Count() > 0).ToList();

            foreach (var user in userList)
            {
                var        email      = user.EmailID;
                MailHelper mailHelper = new MailHelper();
                var        type       = ((SubscriberReminderEnum)Enum.ToObject(typeof(SubscriberReminderEnum), reminderId)).GetEnumDisplayName();
                try
                {
                    mailHelper.ToEmail = email;
                    mailHelper.Subject = "Reminder Mail";

                    if (reminderId == Convert.ToInt32(SubscriberReminderEnum.PaymentOverdue))
                    {
                        mailHelper.Body = CommonFunction.PaymentOverDueReminderMailBody(user.Name, type);
                    }
                    else if (reminderId == Convert.ToInt32(SubscriberReminderEnum.TrailPeriod))
                    {
                        mailHelper.Body = CommonFunction.TrailPeriodReminderMailBody(user.Name, type);
                    }
                    else if (reminderId == Convert.ToInt32(SubscriberReminderEnum.AfterTrailPeriod))
                    {
                        mailHelper.Body = CommonFunction.AfterTrailPeriodReminderMailBody(user.Name, type);
                    }
                    mailHelper.SendEmail();
                }
                catch
                {
                    return(false);
                }
            }
            return(true);
        }