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);
        }
        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);
        }