public ActionResult Create() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) return AccessDeniedView(); var model = new EmailAccountModel(); //default values model.Port = 25; return View(model); }
public ActionResult ChangePassword(EmailAccountModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) //No email account found with the specified id return RedirectToAction("List"); //do not validate model emailAccount.Password = model.Password; _emailAccountService.UpdateEmailAccount(emailAccount); SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Fields.Password.PasswordChanged")); return RedirectToAction("Edit", new { id = emailAccount.Id }); }
public ActionResult Create(EmailAccountModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) return AccessDeniedView(); if (ModelState.IsValid) { var emailAccount = model.ToEntity(); _emailAccountService.InsertEmailAccount(emailAccount); SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Added")); return continueEditing ? RedirectToAction("Edit", new { id = emailAccount.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }
public ActionResult SendTestEmail(EmailAccountModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) return AccessDeniedView(); var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) //No email account found with the specified id return RedirectToAction("List"); try { if (String.IsNullOrWhiteSpace(model.SendTestEmailTo)) throw new NopException("Enter test email address"); var from = new MailAddress(emailAccount.Email, emailAccount.DisplayName); var to = new MailAddress(model.SendTestEmailTo); string subject = _storeContext.CurrentStore.Name + ". Testing email functionality."; string body = "Email works fine."; _emailSender.SendEmail(emailAccount, subject, body, from, to); SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.SendTestEmail.Success"), false); } catch (Exception exc) { ErrorNotification(exc.Message, false); } //If we got this far, something failed, redisplay form return View(model); }
public ActionResult Edit(EmailAccountModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) return AccessDeniedView(); var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) //No email account found with the specified id return RedirectToAction("List"); if (ModelState.IsValid) { emailAccount = model.ToEntity(emailAccount); _emailAccountService.UpdateEmailAccount(emailAccount); SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Updated")); return continueEditing ? RedirectToAction("Edit", new { id = emailAccount.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }