public virtual IActionResult ChangePassword(EmailAccountModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) { return(AccessDeniedView()); } //try to get an email account with the specified id var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) { return(RedirectToAction("List")); } //do not validate model emailAccount.Password = model.Password; _emailAccountService.UpdateEmailAccount(emailAccount); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Fields.Password.PasswordChanged")); return(RedirectToAction("Edit", new { id = emailAccount.Id })); }
public ActionResult SendTestEmail(EmailAccountModel model) { var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); try { string subject = "Hello Mote"; string body = "Email works fine."; if (emailAccount == null) { //No email account found with the specified id return(RedirectToAction("List")); } _emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName, model.SendTestEmailTo, null); } catch (Exception exc) { //ErrorNotification(exc.Message, false); } return(View(model)); }
public IActionResult SaveEmailAccount(EmailAccountModel model) { var emailAccount = model.Id > 0 ? _emailAccountService.Get(model.Id) : new EmailAccount(); if (emailAccount == null) { return(NotFound()); } _modelMapper.Map(model, emailAccount, nameof(EmailAccount.Id), nameof(EmailAccount.Password)); if (!model.Password.IsNullEmptyOrWhiteSpace()) { emailAccount.Password = _cryptographyService.Encrypt(model.Password); } _emailAccountService.InsertOrUpdate(emailAccount); if (model.IsDefault) { //mark all the others as non default _emailSenderSettings.DefaultEmailAccountId = emailAccount.Id; _settingService.Save(_emailSenderSettings, CurrentStore.Id); } return(R.Success.Result); }
public async Task <IActionResult> ChangePassword(EmailAccountModel model) { var emailAccount = await _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) { //No email account found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { //do not validate model await _emailAccountViewModelService.ChangePasswordEmailAccountModel(emailAccount, model); SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Fields.Password.PasswordChanged")); } else { ErrorNotification(ModelState); } return(RedirectToAction("Edit", new { id = emailAccount.Id })); }
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 storeSettings = EngineContext.Current.Resolve <StoreInformationSettings>(); var subject = storeSettings.Name + ". Testing email functionality."; var body = "Email works fine."; _emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName, model.SendTestEmailTo, null); 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 SendTestEmail(EmailAccountModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) { return(AccessDeniedView()); } var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) { throw new ArgumentException("No email account found with the specified id"); } 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 = _storeSettings.StoreName + ". 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 SendTestEmail(EmailAccountModel model) { var emailAccount = _emailAccountService.GetEmailAccountById(model.Id); if (emailAccount == null) { return(RedirectToAction("List")); } try { if (model.SendTestEmailTo.IsEmpty()) { NotifyError(T("Admin.Common.EnterEmailAdress")); } else { var to = new EmailAddress(model.SendTestEmailTo); var from = new EmailAddress(emailAccount.Email, emailAccount.DisplayName); var subject = string.Concat(_storeContext.CurrentStore.Name, ". ", T("Admin.Configuration.EmailAccounts.TestingEmail")); var body = T("Admin.Common.EmailSuccessfullySent"); var msg = new EmailMessage(to, subject, body, from); _emailSender.SendEmail(new SmtpContext(emailAccount), msg); NotifySuccess(T("Admin.Configuration.EmailAccounts.SendTestEmail.Success"), false); } } catch (Exception ex) { model.TestEmailShortErrorMessage = ex.ToAllMessages(); model.TestEmailFullErrorMessage = ex.ToString(); } return(View(model)); }
public virtual ActionResult Create(EmailAccountModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var emailAccount = model.ToEntity(); //set password manually emailAccount.Password = model.Password; _emailAccountService.InsertEmailAccount(emailAccount); //activity log _customerActivityService.InsertActivity("AddNewEmailAccount", _localizationService.GetResource("ActivityLog.AddNewEmailAccount"), emailAccount.Id); 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 Add() { var model = new EmailAccountModel(); return(View("Create", model)); }
public void SendFeedback_ReturnsModelWithResult_ShouldBeReturnsError() { // Arrange var fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization()); var emailServiceConfigurationModel = fixture.Freeze <Mock <IOptions <EmailServiceConfigurationModel> > >(); var userFeedbackRequestModel = new UserFeedbackRequestModel { EmailTo = "EmailTo", Subject = "Subject", TextBody = "TextBody", UserName = "******" }; var emailAccountModel = new EmailAccountModel { EmailFrom = emailServiceConfigurationModel.Object.Value.EmailFrom, Id = emailServiceConfigurationModel.Object.Value.Id, HiddenEmail = emailServiceConfigurationModel.Object.Value.HiddenEmail, InputEnableSSL = emailServiceConfigurationModel.Object.Value.InputEnableSSL, InputHost = emailServiceConfigurationModel.Object.Value.InputHost, Login = emailServiceConfigurationModel.Object.Value.Login, OutputPort = emailServiceConfigurationModel.Object.Value.OutputPort, Password = emailServiceConfigurationModel.Object.Value.Password, UseDefaultCredentials = emailServiceConfigurationModel.Object.Value.UseDefaultCredentials, OutputEnableSSL = emailServiceConfigurationModel.Object.Value.OutputEnableSSL, OutputHost = emailServiceConfigurationModel.Object.Value.OutputHost, InputPort = emailServiceConfigurationModel.Object.Value.InputPort }; var emailRequestModel = new EmailRequestModel { EmailTo = "EmailTo", EmailAccount = emailAccountModel }; var userSupportService = fixture.Freeze <Mock <IUserSupportService> >(); // new UserSupportService(mapper.Object, emailService.Object, emailServiceConfigurationModel.Object); var emailService = fixture.Freeze <Mock <IEmailService> >(); emailService.Setup(s => s.Send(emailRequestModel)) .Returns(new EmailResultModel { IsSended = true, Message = "Сообщение успешно отправлено." }); userSupportService.Setup(s => s.PrepareUserFeedbackRequestForEmailService(userFeedbackRequestModel)) .Returns(emailRequestModel); fixture.Inject(emailService); fixture.Inject(userSupportService); // Act var resultService = fixture.Create <IUserSupportService>(); var result = resultService.SendFeedback(userFeedbackRequestModel); // Assert Assert.AreEqual(false, result.IsSended); }
public virtual async Task SendTestEmail(EmailAccount emailAccount, EmailAccountModel model) { string subject = "Testing email functionality."; string body = "Email works fine."; await _emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName, model.SendTestEmailTo, null); }
public virtual async Task <EmailAccount> UpdateEmailAccountModel(EmailAccount emailAccount, EmailAccountModel model) { emailAccount = model.ToEntity(emailAccount); if (!string.IsNullOrEmpty(model.Password)) { emailAccount.Password = model.Password; } await _emailAccountService.UpdateEmailAccount(emailAccount); return(emailAccount); }
public static EmailAccount ToEntity(this EmailAccountModel model) { return(Mapper.Map <EmailAccountModel, EmailAccount>(model)); }
public static EmailAccount ToEntity(this EmailAccountModel model) { return(TypeAdapter.Adapt <EmailAccountModel, EmailAccount>(model)); }
public virtual EmailAccount ChangePasswordEmailAccountModel(EmailAccount emailAccount, EmailAccountModel model) { emailAccount.Password = model.Password; _emailAccountService.UpdateEmailAccount(emailAccount); return(emailAccount); }
public virtual EmailAccount UpdateEmailAccountModel(EmailAccount emailAccount, EmailAccountModel model) { emailAccount = model.ToEntity(emailAccount); _emailAccountService.UpdateEmailAccount(emailAccount); return(emailAccount); }
public static EmailAccount ToEntity(this EmailAccountModel model, EmailAccount entity) { MapperFactory.Map(model, entity); return(entity); }
public IActionResult Create() { var model = new EmailAccountModel(); return(View(model)); }
public static EmailAccount ToEntity(this EmailAccountModel model, EmailAccount destination) { return(TypeAdapter.Adapt(model, destination)); }
public static EmailAccount ToEntity(this EmailAccountModel model) { return(model.MapTo <EmailAccountModel, EmailAccount>()); }
public static EmailAccount ToEntity(this EmailAccountModel model, EmailAccount destination) { return(Mapper.Map(model, destination)); }
public virtual async Task <EmailAccount> UpdateEmailAccountModel(EmailAccount emailAccount, EmailAccountModel model) { emailAccount = model.ToEntity(emailAccount); await _emailAccountService.UpdateEmailAccount(emailAccount); return(emailAccount); }
public static EmailAccount ToEntity(this EmailAccountModel model, EmailAccount destination) { return(model.MapTo(destination)); }
public virtual async Task <EmailAccount> ChangePasswordEmailAccountModel(EmailAccount emailAccount, EmailAccountModel model) { emailAccount.Password = model.Password; await _emailAccountService.UpdateEmailAccount(emailAccount); return(emailAccount); }