public ActionResult PDYfkXYuBGyPhWgzDhBQsRnUkQjZKAtC()
        {
            DateTime today = DateTime.Now;

            //Instantiate and create a new email message
            SmtpClient  client       = new SmtpClient();
            MailMessage autoReminder = new MailMessage();

            //autoReminder.From = new MailAddress("*****@*****.**");
            autoReminder.Subject = "Automatic Reminder: Your event today at Challenged Champions Equestrian Center";
            autoReminder.Body    = "This is an automated message reminding you that you've signed up for an event today. Please check the \"My Schedule\" portion of the volunteer website for more information about this event.";
            autoReminder.To.Add("*****@*****.**");

            VolunteersDBEntities _db = new VolunteersDBEntities();

            foreach (string email in _db.TodaysVolunteers(today.Date))
            {
                autoReminder.Bcc.Add(email);
            }

            if (autoReminder.To.Count != 0)
            {
                client.Send(autoReminder);
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }

            return(RedirectToAction("Login", "Login"));
        }
        public ActionResult TextVolunteers()
        {
            VolunteersDBEntities _db = new VolunteersDBEntities();

            ViewData.Model = _db.Volunteers.OrderByDescending(x => x.Active).ThenBy(x => x.Position).ToList();
            return(View());
        }
        public JsonResult Communications(int EmailFlag, string subject, string message)
        {
            int counter = 0;

            using (VolunteersDBEntities _db = new VolunteersDBEntities())
            {
                List <Volunteer> volunteerList = new List <Volunteer>();
                if (EmailFlag == 1)
                {
                    volunteerList = _db.Volunteers.Where(v => v.Position == "Walker                   ").ToList();
                }
                else if (EmailFlag == 2)
                {
                    var currentDate = DateTime.Now.Date;
                    IQueryable <Event> eventList = _db.Events.Where(v => v.EventDate == currentDate);
                    foreach (var e in eventList)
                    {
                        Volunteer v = e.Volunteers.FirstOrDefault();
                        if (v != null)
                        {
                            volunteerList.Add(v);
                        }
                    }
                }

                foreach (Volunteer v in volunteerList)
                {
                    SendEmail(v.Email, subject, message);
                    counter++;
                }
            }

            return(Json(counter));
        }
        public ActionResult AdminUnScheduleVolunteer(int volunteerID, int eventID)
        {
            ScheduleVolunteerDBEntities x = new ScheduleVolunteerDBEntities();

            x.unSchedule_Volunteer(volunteerID, eventID);

            EventDBEntities _Edb   = new EventDBEntities();
            var             events = _Edb.Events.ToList();

            Models.Event myEvent = (Models.Event)(events.Where(y => y.EventID == eventID).FirstOrDefault());

            VolunteersDBEntities _Vdb = new VolunteersDBEntities();
            var volunteers            = _Vdb.Volunteers.ToList();

            Models.Volunteer myVolunteer = (Models.Volunteer)(volunteers.Where(z => z.ID == volunteerID).FirstOrDefault());

            //notify volunteer of schedule change
            SmtpClient  client          = new SmtpClient();
            MailMessage notifyVolunteer = new MailMessage();

            notifyVolunteer.Subject = "You have been unscheduled from an event at the Challenged Champions Equestrian Center";
            notifyVolunteer.Body    = "This is an automated message informing you that an administrator has unscheduled you from the following event: "
                                      + myEvent.EventTitle + " on " + myEvent.EventDate.ToString("MM-dd-yyyy")
                                      + ". Please check the \"My Schedule\" portion of the volunteer website to review your schedule.";
            notifyVolunteer.To.Add(myVolunteer.Email);

            client.Send(notifyVolunteer);

            return(new EmptyResult());
        }
        public ActionResult GetDetail(int id)
        {
            VolunteersDBEntities _db = new VolunteersDBEntities();
            var volunteerList        = _db.Volunteers.ToList();
            var Model = volunteerList.Where(x => x.ID == id).FirstOrDefault();

            return(PartialView("EditVolunteerPartial", Model));
        }
        public ActionResult ManageAccount()
        {
            VolunteersDBEntities _db = new VolunteersDBEntities();
            var volunteerList        = _db.Volunteers.ToList();
            var Model = volunteerList.Where(x => x.ID == currentUserId).FirstOrDefault();

            return(View(Model));
        }
        public ActionResult AdminHome(long id = -1)
        {
            if (id != -1)
            {
                currentUser = id;
            }

            VolunteersDBEntities _db = new VolunteersDBEntities();
            var volunteerList        = _db.Volunteers.ToList();
            var Model = volunteerList.Where(x => x.ID == currentUserId).FirstOrDefault();

            return(View(Model));
        }
        public ActionResult ResetPassword(string code)
        {
            ResetPasswordViewModel model = new ResetPasswordViewModel();

            using (VolunteersDBEntities db = new VolunteersDBEntities())
            {
                Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.GUID == code);
                if (currentUser != null)
                {
                    model.Code = currentUser.GUID;
                }
            }
            return(View(model));
        }
        public ActionResult Login(Volunteer user)
        {
            VolunteersDBEntities _db = new VolunteersDBEntities();

            if (EmailValidation(user.Email) && PasswordValidation(user.Password))
            {
                //if (EmailValidation(user.Email), PasswordValidation(user.Password))
                //ComputeHash code here to check with the database
                var       salt           = new Byte[16];
                string    hashedPassword = HashPassword(user.Password);
                Volunteer currentUser    = _db.Volunteers.FirstOrDefault(v => v.Email == user.Email);
                long      currentUserId  = 0;
                if (currentUser != null)
                {
                    currentUserId = currentUser.ID;
                }
                string userId = _db.ValidateUser(currentUserId, hashedPassword).FirstOrDefault();

                string message = string.Empty;

                if (userId == "false")
                {
                    message = "Username and/or password is incorrect.";
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(user.Email, true);
                    string adminUser = _db.Check_Admin((int)currentUserId).FirstOrDefault();

                    if (adminUser == "true")
                    {
                        return(RedirectToAction("AdminHome", "Home", new { id = currentUserId }));
                    }
                    else
                    {
                        return(RedirectToAction("MySchedule", "Home", new { id = currentUserId }));
                    }
                }

                ViewBag.Message = message;
            }
            else
            {
                string message = "Username and/or password is incorrect.";
                ViewBag.Message = message;
            }
            return(View(user));
        }
        public ActionResult SeeVolunteersSignedUp(int eventID)
        {
            VolunteersDBEntities _db = new VolunteersDBEntities();
            var volunteerList        = _db.VolunteersSignedUp(eventID);

            if (volunteerList.FirstOrDefault().FirstName == null)
            {
                throw new Exception();
            }

            Models.AdminCalVolunteerPerEventPartialModel Model = new Models.AdminCalVolunteerPerEventPartialModel
            {
                event_ID   = eventID,
                volunteers = volunteerList
            };

            return(PartialView("AdminCalVolunteerPerEventPartial", Model));
        }
        public ActionResult ChangePhone(ChangePhoneViewModel model)
        {
            using (VolunteersDBEntities db = new VolunteersDBEntities())
            {
                if (PhoneValidation(model.Phone))
                {
                    Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name);
                    if (currentUser != null)
                    {
                        currentUser.Phone = model.Phone;
                        db.SaveChanges();
                        return(View("ChangePhoneConfirmation"));
                    }
                }
            }
            string message = "Invalid phone number entered. Do not use - and make sure your phone number is 10 digits long.";

            ViewBag.Message = message;
            return(View());
        }
        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            if (PasswordValidation(model.Password) && PasswordValidation(model.ConfirmPassword) && model.Password == model.ConfirmPassword)
            {
                using (VolunteersDBEntities db = new VolunteersDBEntities())
                {
                    Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.GUID == model.Code);
                    if (currentUser != null)
                    {
                        currentUser.Password = HashPassword(model.Password);
                        db.SaveChanges();
                        return(View("ResetPasswordConfirmation"));
                    }
                }
            }
            string message = "Passwords entered did not match input validation expectations. Make sure passwords are between 8-15 characters and that password and confirm password match.";

            ViewBag.Message = message;
            return(View(model));
        }
        public ActionResult ChangePassword(ChangePasswordViewModel model)
        {
            using (VolunteersDBEntities db = new VolunteersDBEntities())
            {
                if (PasswordValidation(model.OldPassword) && PasswordValidation(model.NewPassword) && PasswordValidation(model.ConfirmNewPassword) && (model.NewPassword == model.ConfirmNewPassword))
                {
                    string    hashPassword = HashPassword(model.OldPassword);
                    Volunteer currentUser  = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name && u.Password == hashPassword);
                    if (currentUser != null)
                    {
                        currentUser.Password = HashPassword(model.NewPassword);
                        db.SaveChanges();
                        return(View("ChangePasswordConfirmation"));
                    }
                }
            }
            string message = "Passwords entered did not match input validation expectations. Make sure passwords are between 8-15 characters.";

            ViewBag.Message = message;
            return(View());
        }
        public ActionResult ChangeEmail(ChangeEmailViewModel model)
        {
            using (VolunteersDBEntities db = new VolunteersDBEntities())
            {
                if (EmailValidation(model.Email) && PasswordValidation(model.Password))
                {
                    string    hashPassword = HashPassword(model.Password);
                    Volunteer currentUser  = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name && u.Password == hashPassword);
                    if (currentUser != null)
                    {
                        currentUser.Email = model.Email;
                        db.SaveChanges();
                        FormsAuthentication.SetAuthCookie(currentUser.Email, true);
                        return(View("ChangeEmailConfirmation"));
                    }
                }
            }
            string message = "Invalid email address or password. Please try again.";

            ViewBag.Message = message;
            return(View());
        }
Beispiel #15
0
        public ActionResult TextTodaysVolunteers()
        {
            DateTime today = DateTime.Now;

            VolunteersDBEntities _db = new VolunteersDBEntities();

            var accountsid = "AC1e234cf4a6742315d15d6d0f457c3d55";
            var authToken  = "8f0c777ebd152c1145b6c90f82d29ac4";

            TwilioClient.Init(accountsid, authToken);

            var from = new PhoneNumber("+14193703444");

            foreach (string email in _db.TodaysVolunteersPhone(today.Date))
            {
                var message = MessageResource.Create(
                    to: "+1" + email,
                    from: from,
                    body: "This is an automated message from Challenged Champions Equestrian Center. Reminder: you are signed up for an event today!"
                    );
            }

            return(RedirectToAction("Communications", "Home"));
        }
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (VolunteersDBEntities db = new VolunteersDBEntities())
                {
                    if (EmailValidation(model.Email))
                    {
                        Volunteer forgetUser = db.Volunteers.FirstOrDefault(u => u.Email == model.Email);
                        if (forgetUser != null)
                        {
                            forgetUser.GUID = Guid.NewGuid().ToString();
                            db.SaveChanges();
                            SendEmail(forgetUser.Email, "Reset Password", "Your reset password link is http://" + Request.Url.Authority + "/Account/ResetPassword?code=" + forgetUser.GUID);
                            return(View("ForgotPasswordConfirmation"));
                        }
                    }
                }
            }
            string message = "invalid email entered. Please try again.";

            ViewBag.Message = message;
            return(View(model));
        }