Ejemplo n.º 1
0
        internal static void sendEmailToAffi(Product.ProudctType productType)
        {
            var          emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            MailContent mail = new MailContent();

            mail.MailingAdress  = getAFFIToAddress();
            mail.MailFrom       = getFromAddress();
            mail.ReplyToAddress = getReplyToAddress();
            //AFFI English
            //if (productType == Product.ProudctType.AffiEnglish)
            //{
            mail.Subject  = getAFFIEmailSubject();
            mail.HtmlText = getEmaiBodyforAffi();
            //}
            //AFFI Spanish
            //else
            //{
            //    mail.Subject = getAFFISpanishEmailSubject();
            //    mail.HtmlText = getEmaiBodyforAffiSpanish();
            //}

            mailService.sendMail(mail, true);
        }
Ejemplo n.º 2
0
        internal static void sendEmailToUser(string email, Product.ProudctType productType)
        {
            var          emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            MailContent mail = new MailContent();

            mail.MailingAdress  = email;
            mail.MailFrom       = getFromAddress();
            mail.ReplyToAddress = getReplyToAddress();

            //AFFI English
            if (productType == Product.ProudctType.AffiEnglish)
            {
                mail.Subject  = getAFFIEmailSubject();
                mail.HtmlText = getEmailBodyForUserAFFISite();
            }
            //AFFI Spanish
            else
            {
                mail.Subject  = getAFFISpanishEmailSubject();
                mail.HtmlText = getEmailBodyForUserAFFISpanishSite();
            }

            mailService.sendMail(mail, true);
        }
Ejemplo n.º 3
0
        internal static void sendErrorEmail(string message)
        {
            var          emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            var emailRecipient = System.Configuration.ConfigurationManager.AppSettings["errorEmailRecipient"];

            MailContent mail = new MailContent();

            mail.MailingAdress = emailRecipient;
            mail.MailFrom      = getFromAddress();
            mail.Subject       = "AFFI Signup Error";
            mail.HtmlText      = message;
            mailService.sendMail(mail, true);
        }
        public ActionResult Activate(PurchasedItemModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("Index"));
            }

            string facilityName   = model.Facility;
            string userName       = model.Name;
            string email          = model.Email;
            string dateOfPurchase = model.DateOfPurchase;
            List <PurchasedItem> purchasedItems = GetStoredPurchasedItems();

            if (purchasedItems == null)
            {
                return(LogOutAndRedirectToLoginPage());
            }
            DateTime date = DateTime.Parse(dateOfPurchase);

            var purchasedItem = purchasedItems.Find(i => Math.Abs(i.DateOfPurchase.Subtract(date).TotalSeconds) < 1);

            if (purchasedItem != null)
            {
                var count = context.UserPurchases.Where(u => EntityFunctions.DiffSeconds(u.DateOfPurchase, purchasedItem.DateOfPurchase) < 1).Count();

                //if(count != 0)
                //    return Content("<html><head></head><body><h1>Error! This item already activated </h1></body></html>");


                var salt = GenerateSequenceOfChars(20);
                // TODO: check facility name length
                var password = GeneratePassword(facilityName);

                //TODO: move following code to method
                var userPurchase = new UserPurchase();

                userPurchase.Email                = email;
                userPurchase.ActivatorsEmail      = User.Identity.Name;
                userPurchase.Name                 = userName;
                userPurchase.PasswordSalt         = salt;
                userPurchase.Password             = HashPassword(password, salt);
                userPurchase.FacilityName         = facilityName;
                userPurchase.DateOfPurchase       = purchasedItem.DateOfPurchase;
                userPurchase.UserRegistrationDate = DateTime.Now;
                userPurchase.UserExpirationDate   = DateTime.Now.AddMonths(6);

                context.UserPurchases.Add(userPurchase);
                context.SaveChanges();

                HttpContext.Session["lastPurchase"]         = userPurchase;
                HttpContext.Session["lastPurchasePassword"] = password;

                //Send an email to user
                IMailService mailService = new SmptMailService(System.Configuration.ConfigurationManager.AppSettings["smtpServer"]);

                MailContent mailContent = new MailContent();
                mailContent.MailFrom      = "*****@*****.**";
                mailContent.MailingAdress = userPurchase.Email;
                mailContent.Subject       = "AFFI FSMA Self-Assessment Login Credentials and Instructions";

                mailContent.HtmlText = "<html><head></head><body>Dear " + userPurchase.Name + ":<br/>" +
                                       "<p>When you want to begin your FSMA Self-Assessment for your facility (<b>" + userPurchase.FacilityName + "</b>), you can just click on the Login link below.</p>" +
                                       "<p>Your login credentials for the FSMA Self-Assessment are: </p>" +
                                       "<p><b>Userid: </b>" + userPurchase.Email + "</p>" +
                                       "<p><b>Password: </b>" + password + "</p>" +
                                       "<p>If you have any questions regarding the FSMA Self-Assessment Tool, please contact AFFI Vice President of Regulatory and Technical Affairs Dr. Donna Garren at <a href=\"mailto:[email protected]\">[email protected]</a> or (703) 821-0770.</p>" +
                                       "<p>Thank you.</p>" +
                                       "<p><a href=\"http://affi-fsma.seneca.com/signIn\" target=\"_blank\">Click Here to Login</a></p></body></html>";

                mailContent.PlainText = mailContent.HtmlText;
                mailService.sendMail(mailContent);

                //And if needed - to a person who had activated the purchase (if not same person)
                if (userPurchase.Email != userPurchase.ActivatorsEmail)
                {
                    mailContent.MailingAdress = userPurchase.ActivatorsEmail;
                    mailService.sendMail(mailContent);
                }

                return(Redirect("Index"));
            }
            else
            {
                return(Content("<html><head></head><body><h1>Error!Can't find purchasedItem</h1></body></html>"));
            }
        }