Ejemplo n.º 1
0
 public ActionResult Create()
 {
     var model = new EmailAccountModel();
     //default values
     model.Port = 25;
     return View(model);
 }
Ejemplo n.º 2
0
        public ActionResult Create(EmailAccountModel model)
        {
            if (ModelState.IsValid)
            {
                var emailAccount = model.ToEntity();

                // encrypt the password
                var encryptionService = EngineContext.Current.Resolve<IEncryptionService>();
                emailAccount.Password = encryptionService.AESEncrypt(model.Password);

                emailAccountService.Insert(emailAccount);

                SuccessNotification(localizationService.GetResource("Configuration.EmailAccounts.Added"));
                return RedirectToAction("Index");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult SendTestEmail(EmailAccountModel model)
        {
            var emailAccount = emailAccountService.GetById(model.RowId);
            if (emailAccount == null)
                //No email account found with the specified id
                return RedirectToAction("Index");

            try
            {
                if (String.IsNullOrWhiteSpace(model.SendTestEmailTo))
                    throw new SiteException("Enter test email address");

                var from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
                var to = new MailAddress(model.SendTestEmailTo);
                string subject = siteSettings.SiteName + ". Testing email functionality.";
                string body = "Email works fine.";
                emailSender.SendEmail(emailAccount, subject, body, from, to);
                SuccessNotification(localizationService.GetResource("Configuration.EmailAccounts.SendTestEmail.Success"), false);
            }
            catch (Exception exc)
            {
                ErrorNotification(exc.Message, false);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 4
0
        public ActionResult Edit(EmailAccountModel model)
        {
            var emailAccount = emailAccountService.GetById(model.RowId);
            if (emailAccount == null)
                //No email account found with the specified id
                return RedirectToAction("Index");

            if (ModelState.IsValid)
            {
                emailAccount = model.ToEntity(emailAccount);

                // encrypt the password
                var encryptionService = EngineContext.Current.Resolve<IEncryptionService>();
                emailAccount.Password = encryptionService.AESEncrypt(model.Password);

                emailAccountService.Update(emailAccount);

                SuccessNotification(localizationService.GetResource("Configuration.EmailAccounts.Updated"));
                return RedirectToAction("Index");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }