Exemple #1
0
        public ActionResult SendPasswordResetEmail(string userEmail)
        {
            var drResetPassword = CRCDataAccess.SaveCRCUserPasswordReset(userEmail, null);

            if (drResetPassword != null)
            {
                InfEmail.AddToQueue(
                    "Reset Password",
                    new
                {
                    ResetPasswordLink   = string.Format(CultureInfo.InvariantCulture, "{0}?token={1}", Url.Action("ResetPassword", "Home", null, Request.Url.Scheme), drResetPassword["Token"].ToString()),
                    CRCUserFirstName    = drResetPassword["CRCUserFirstName"].ToString(),
                    CRCUserLastName     = drResetPassword["CRCUserLastName"].ToString(),
                    CRCUserEmail        = drResetPassword["CRCUserEmail"].ToString(),
                    CRCManagerFirstName = drResetPassword["CRCManagerFirstName"].ToString(),
                    CRCManagerLastName  = drResetPassword["CRCManagerLastName"].ToString(),
                    CRCManagerEmail     = drResetPassword["CRCManagerEmail"].ToString(),
                    CRCManagerPhone     = drResetPassword["CRCManagerPhone"].ToString(),
                    CRCManagerJobTitle  = drResetPassword["CRCManagerJobTitle"].ToString()
                },
                    CRCUser != null ? CRCUser.UserId : (long)drResetPassword["UserId"]);

                return(Json(true));
            }

            return(Json(false));
        }
        public ActionResult ForgotPassword(ForgotPasswordViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var drResetPassword = CRCDataAccess.SaveCRCUserPasswordReset(viewModel.Email, null);
                if (drResetPassword != null)
                {
                    InfEmail.AddToQueue(
                        "Reset Password",
                        new
                    {
                        ResetPasswordLink   = string.Format(CultureInfo.InvariantCulture, "{0}?token={1}", Url.Action("ResetPassword", "Home", null, Request.Url.Scheme), drResetPassword["Token"].ToString()),
                        CRCUserFirstName    = drResetPassword["CRCUserFirstName"].ToString(),
                        CRCUserLastName     = drResetPassword["CRCUserLastName"].ToString(),
                        CRCUserEmail        = drResetPassword["CRCUserEmail"].ToString(),
                        CRCManagerFirstName = drResetPassword["CRCManagerFirstName"].ToString(),
                        CRCManagerLastName  = drResetPassword["CRCManagerLastName"].ToString(),
                        CRCManagerEmail     = drResetPassword["CRCManagerEmail"].ToString(),
                        CRCManagerPhone     = drResetPassword["CRCManagerPhone"].ToString(),
                        CRCManagerJobTitle  = drResetPassword["CRCManagerJobTitle"].ToString()
                    },
                        CRCUser != null ? CRCUser.UserId : (long)drResetPassword["UserId"]);

                    viewModel.Status = true;
                    return(View(viewModel));
                }
            }

            viewModel.Status = false;
            return(View(viewModel));
        }
Exemple #3
0
        public ActionResult NewUserRequest(
            string First_Name_NU,
            string Last_Name_NU,
            string Email_NU,
            string Phone_NU,
            string Call_Letters_NU,
            string Title_NU
            )
        //public ActionResult NewUserRequest(
        //	string emailBody
        //)
        {
            var viewModel    = new SignInViewModel();
            var drCRCManager = CRCDataAccess.GetCRCManager();

            if (drCRCManager != null)
            {
                viewModel.CRCManagerEmail      = drCRCManager["Email"].ToString();
                viewModel.CRCManagerPhone      = drCRCManager["Phone"].ToString();
                viewModel.CRCManagerFirstName  = drCRCManager["FirstName"].ToString();
                viewModel.CRCManagerMiddleName = drCRCManager["MiddleName"].ToString();
                viewModel.CRCManagerLastName   = drCRCManager["LastName"].ToString();
                viewModel.userId = Convert.ToInt64(drCRCManager["UserId"]);
                //viewModel.Email = Session["useremail"].ToString();
            }
            string UserEmail = CRCUser.Email;
            string emailBody = viewModel.CRCManagerFirstName + " - Please Add the User below to station: " + Call_Letters_NU + "\n\n";

            emailBody += "First Name: " + "  " + First_Name_NU;
            emailBody += "\n" + "Last Name:" + "  " + Last_Name_NU;
            emailBody += "\n" + "Email: " + "  " + Email_NU;
            emailBody += "\n" + "Phone: " + "  " + Phone_NU;
            emailBody += "\n" + "Call Letters: " + "  " + Call_Letters_NU;
            emailBody += "\n" + "Title: " + "  " + Title_NU;
            emailBody += "\n" + "Submitted By:" + "  " + UserEmail;



            InfEmail.AddToQueue(UserEmail, viewModel.CRCManagerEmail, "New CRC User Request: " + Call_Letters_NU, emailBody, 1);
            //try
            //{
            //	CRCDataAccess.RemoveUserStationLink(userId, stationId);
            //}
            //catch (EntitySqlException e)
            //{
            //	Console.Write(e);
            //}


            //if (primaryUserId.HasValue)
            //{

            //	if (userId == primaryUserId)
            //	{
            //		CRCDataAccess.UpdatePrimaryUserStatus(stationId);
            //	}
            //}
            return(Json("1", JsonRequestBehavior.AllowGet));
        }
 public ActionResult StartEmailQueue()
 {
     try
     {
         InfEmail.StartQueue();
         return(Content("The email queue was started successfully."));
     }
     catch (Exception exception)
     {
         var baseException = exception.GetBaseException();
         InfLogger.Log(baseException);
         return(Content(string.Format(CultureInfo.InvariantCulture, "An error occurred while attempting to start the email queue: {0}", baseException.Message)));
     }
 }
        private static void InitEmail()
        {
            InfEmail.AutoStartQueue   = ConfigurationManager.AppSettings["Inf:AutoStartEmailQueue"].TryConvertTo <bool>(false);
            InfEmail.QueueInterval    = TimeSpan.FromSeconds(ConfigurationManager.AppSettings["Inf:EmailQueueIntervalSeconds"].TryConvertTo <int>(10));
            InfEmail.MaxRetryAttempts = ConfigurationManager.AppSettings["Inf:MaxEmailRetryAttempts"].TryConvertTo <int>(5);

            if (InfEmail.AutoStartQueue)
            {
                try
                {
                    InfEmail.StartQueue();
                }
                catch (Exception exception)
                {
                    InfLogger.Log(exception);
                }
            }
        }
        public ActionResult SendEmail()
        {
            var model = new SignInViewModel();
            //string to = "*****@*****.**";
            string to      = model.CRCManagerEmail.ToString();
            string from    = model.Email.ToString();
            string subject = "Help with CRC site";
            string body    = "<html><body><h3>Testing Mail</h3></body></html>";
            long   userID  = model.userId;

            using (var email = new MailMessage(from, to, subject, body))
            {
                email.IsBodyHtml = true;
                //email.CC.Add(cc);
                email.Priority = MailPriority.High;
                InfEmail.AddToQueue(email, userID);
            }

            //      return to + " " + from + " " + subject + " " + body + " " + userID;

            return(View());
        }