Esempio n. 1
0
        public ActionResult Index([Bind(Include = "Title,EmailText,Recipients")] HfedEmail hfedEmail)
        {
            if (hfedEmail != null)
            {
                foreach (HfedEmailRecipient recipient in hfedEmail.Recipients)
                {
                    if (recipient.Checked)
                    {
                        var text = "<p>";
                        text += hfedEmail.EmailText.Replace(Environment.NewLine, "</p><p>");
                        text += "</p>";
                        DateTime startDate = Convert.ToDateTime(Session["StartDate"]);
                        DateTime endDate   = Convert.ToDateTime(Session["EndDate"]);
                        switch (hfedEmail.Title)
                        {
                        case "Email Drivers - Show Schedule with Driver Names":
                            hfedEmail.HtmlContent = GetDriverSchedule(true, startDate, endDate);
                            break;

                        case "Email Drivers - Show Schedule with No Driver Names":
                            hfedEmail.HtmlContent = GetDriverSchedule(false, startDate, endDate);
                            break;

                        case "Email Reminders":
                            var reminderDate = Convert.ToDateTime(Session["ReminderDate"]);
                            hfedEmail.HtmlContent = GetReminderSchedule(reminderDate);
                            break;

                        case "Email Staff - Request Schedules":
                            hfedEmail.HtmlContent = GetTentativeSchedule();
                            break;
                        }
                        text += hfedEmail.HtmlContent;
                        SendEmail(recipient.Email, text);
                    }
                }
            }

            return(RedirectToAction("Index", "HfedSchedules"));
        }
Esempio n. 2
0
        // GET: HfedEmail/Index
        public ActionResult Index(HfedEmailViewModel email)
        {
            if (email != null)
            {
                TempData.Keep();
                email.Recipients = TempData["Recipients"] as List <HfedEmailRecipient>;

                // Convert to HfedEmail (for different requests to all use Index, a different name of model is needed.)
                HfedEmail model = new HfedEmail()
                {
                    Title       = email.Title,
                    EmailText   = email.EmailText,
                    HtmlContent = email.HtmlContent,
                    Recipients  = email.Recipients
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "HfedSchedules"));
            }
        }