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