示例#1
0
        public ActionResult EmailReminder(string reminderDate)
        {
            var email = new HfedEmailViewModel
            {
                Title = "Email Reminders"
            };
            var text = "Reminder:\n";

            text           += "You have an upcoming HFED delivery:\n ";
            email.EmailText = text;

            if (Session["ReminderDate"] == null)
            {
                Session["ReminderDate"] = DateTime.Today.AddDays(2);
            }
            else
            {
                if (!reminderDate.IsNullOrEmpty())
                {
                    Session["ReminderDate"] = reminderDate;
                }
            }

            DateTime dtReminderDate = Convert.ToDateTime(Session["ReminderDate"]);

            email.HtmlContent = GetReminderSchedule(dtReminderDate);

            GetReminderRecipients(Session["ReminderDate"].ToString()); // Puts Email Rrecipient list in TempData
            TempData.Keep();
            email.Recipients = TempData["Recipients"] as List <HfedEmailRecipient>;

            return(RedirectToAction("Index", email));
        }
示例#2
0
        public HfedEmail GetReminderRecipients(string reminderDate)
        {
            var email = new HfedEmailViewModel();

            email.Recipients = new List <HfedEmailRecipient>();

            List <ApplicationUser> recipients = new List <ApplicationUser>();
            List <ApplicationUser> allUsers   = db.Users.ToList();

            foreach (var user in allUsers)
            {
                if (UserIsInRole(user, "HfedCoordinator"))
                {
                    recipients.Add(user);
                }
            }

            var sqlString = "SELECT * FROM HfedSchedule WHERE Date = '" + reminderDate + "'";
            var schedules = db.Database.SqlQuery <HfedScheduleViewModel>(sqlString).ToList();

            foreach (HfedScheduleViewModel reminder in schedules)
            {
                sqlString = "SELECT * FROM HfedSchedule WHERE Id = " + reminder.Id;
                var schedule = db.Database.SqlQuery <HfedScheduleViewModel>(sqlString).ToList();

                ApplicationUser pointPerson = db.Users.Find(schedule[0].PointPerson_Id);
                recipients.Add(pointPerson);

                if (!reminder.Driver_Id.IsNullOrEmpty())
                {
                    var driver = db.Users.Find(reminder.Driver_Id);
                    recipients.Add(driver);
                }
            }

            var newList = new List <HfedEmailRecipient>();

            foreach (ApplicationUser user in recipients)
            {
                newList.Add(new HfedEmailRecipient()
                {
                    Id = user.Id, FullName = user.FullName, Email = user.Email, Checked = true
                });
            }
            TempData["Recipients"] = newList; // TempData holds complex data not passed in Redirects.
            return(null);
        }
示例#3
0
        // GET: HfedEmail
        public ActionResult EmailStaffAsk()
        {
            var email = new HfedEmailViewModel();

            email.Title = "Email Staff - Request Schedules";
            var text = "Greetings MCCH HFED Team!\n";

            text += " The HFED coordinator has tentatively copied the food delivery" +
                    " schedules from the past month into next month.\n Please sign in to the HFED" +
                    " website at MVC5Seneca.Azurewebsites.net to verify the details including" +
                    " the list of clients.";
            email.EmailText = text;

            var allUsers = db.Users.ToList();
            List <ApplicationUser> recipients = new List <ApplicationUser>();

            foreach (ApplicationUser user in allUsers)
            {
                if (UserIsInRole(user, "HfedStaff") || UserIsInRole(user, "HfedCoordinator"))
                {
                    recipients.Add(user);
                }
            }

            var newList = new List <HfedEmailRecipient>();

            foreach (ApplicationUser user in recipients)
            {
                newList.Add(new HfedEmailRecipient()
                {
                    Id = user.Id, FullName = user.FullName, Email = user.Email, Checked = true
                });
            }

            email.HtmlContent      = GetTentativeSchedule();
            TempData["Recipients"] = newList; // TempData holds complex data not passed in Redirects.
            email.Recipients       = newList;

            return(RedirectToAction("Index", email));
        }
示例#4
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"));
            }
        }
示例#5
0
        public ActionResult  EmailDrivers()    // Ask drivers for availability / show with drivers
        {
            bool withDrivers = (bool)(TempData["WithDrivers"]);
            var  email       = new HfedEmailViewModel
            {
                Title = "Email Drivers - "
            };

            if (withDrivers)
            {
                email.Title += "Show Schedule with Driver Names";
            }
            else
            {
                email.Title += "Show Schedule with No Driver Names";
            }
            var text = "Greetings Team!\n";

            if (withDrivers)
            {
                text += "Thank you for being a part of the team that works to allow ";
                text += "our MCCH residents to have Healthy Food Every Day.\n ";
            }
            else
            {
                text += "Please take a look and let us know which food runs you are ";
                text += "available for and interested in doing. ";
                text += "We will get back to you soon to confirm.\n";
            }

            if (!withDrivers)
            {
                text += "Thank you for helping people have Healthy Food Every Day!";
            }

            email.EmailText = text;
            var startDate = Convert.ToDateTime(Session["StartDate"]);
            var endDate   = Convert.ToDateTime(Session["EndDate"]);

            email.HtmlContent = GetDriverSchedule(withDrivers, startDate, endDate);
            var allUsers = db.Users.ToList();
            List <ApplicationUser> recipients = new List <ApplicationUser>();

            foreach (ApplicationUser user in allUsers)
            {
                if (UserIsInRole(user, "HfedDriver") || UserIsInRole(user, "HfedCoordinator"))
                {
                    recipients.Add(user);
                }
            }

            var newList = new List <HfedEmailRecipient>();

            foreach (ApplicationUser user in recipients)
            {
                newList.Add(new HfedEmailRecipient()
                {
                    Id = user.Id, FullName = user.FullName, Email = user.Email, Checked = true
                });
            }

            TempData["Recipients"] = newList; // TempData holds complex data not passed in Redirects.
            email.Recipients       = newList;
            return(RedirectToAction("Index", email));
        }