Exemplo n.º 1
0
        public IActionResult SaveEmailSettings([FromBody] EmailSettingModel model)
        {
            if (ModelState.IsValid)
            {
                EmailSetting entity = new EmailSetting();

                model.CopyTo(entity);
                int i = 0;
                List <EmailBody> bodies = new List <EmailBody>();
                foreach (var item in model.Name)
                {
                    if (item.IsNotEmpty() && model.Content[i].IsNotEmpty())
                    {
                        bodies.Add(new EmailBody()
                        {
                            Name = item, Content = model.Content[i]
                        });
                    }
                    i++;
                }
                entity.Bodies = bodies;
                return(_settingService.Save(entity).SaveResult(T));
            }
            return(SaveFailure(GetModelErrors()));
        }
Exemplo n.º 2
0
        // GET: Setting 설정 메일서버 설정
        public ActionResult SettingEmail()
        {
            SettingDbModels   db          = new SettingDbModels();
            EmailSettingModel returnModel = db.GetEmailSettingModel();


            return(View(returnModel));
        }
Exemplo n.º 3
0
        public IActionResult EditEmailSetting()
        {
            EmailSettingModel model  = new EmailSettingModel();
            EmailSetting      entity = _settingFinder.Get <EmailSetting>();

            if (entity != null)
            {
                entity.CopyTo(model);
            }

            return(View(model));
        }
Exemplo n.º 4
0
 public ActionResult EmailSetting(EmailSettingModel model)
 {
     try
     {
         UserRepository.SetEmailSend(model.UserID, model.EmailSend, model.PasswordSend, model.SignEmailSend);
         ViewBag.Message = "Thiết lập email thành công";
         StoreData.ReloadData <UserInfo>();
     }
     catch
     {
         ViewBag.Message = "Thiết lập email không thành công, vui lòng thử lại";
     }
     return(RedirectToAction("EmailSetting"));
 }
Exemplo n.º 5
0
        public ActionResult EmailSetting()
        {
            var userInfo = UserContext.GetCurrentUser();

            if (userInfo != null)
            {
                userInfo = UserRepository.GetInfo(userInfo.UserID) ?? new UserInfo();
                var model = new EmailSettingModel
                {
                    UserID          = userInfo.UserID,
                    FullName        = userInfo.FullName,
                    UserName        = userInfo.UserName,
                    EmailSend       = userInfo.EmailSend,
                    PasswordSend    = userInfo.PasswordSend,
                    SignEmailSend   = userInfo.SignEmailSend,
                    ConfirmPassword = userInfo.ConfirmPassword,
                };
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
 public ActionResult EmailSetting(EmailSettingModel model)
 {
     try
     {
         UserRepository.SetEmailSend(model.UserID, model.EmailSend, model.PasswordSend, model.SignEmailSend);
         ViewBag.Message = "Thiết lập email thành công";
         StoreData.ReloadData<UserInfo>();
     }
     catch
     {
         ViewBag.Message = "Thiết lập email không thành công, vui lòng thử lại";
     }
     return RedirectToAction("EmailSetting");
 }
Exemplo n.º 7
0
 public ActionResult EmailSetting()
 {
     var userInfo = UserContext.GetCurrentUser();
     if (userInfo != null)
     {
         userInfo = UserRepository.GetInfo(userInfo.UserID) ?? new UserInfo();
         var model = new EmailSettingModel
                     {
                         UserID = userInfo.UserID,
                         FullName = userInfo.FullName,
                         UserName = userInfo.UserName,
                         EmailSend = userInfo.EmailSend,
                         PasswordSend = userInfo.PasswordSend,
                         SignEmailSend = userInfo.SignEmailSend,
                         ConfirmPassword = userInfo.ConfirmPassword,
                     };
         return View(model);
     }
     return RedirectToAction("Index");
 }
Exemplo n.º 8
0
 private SmtpClient SetUpSmtpClient(EmailSettingModel emailSettings)
 {
     return(new SmtpClient {
         Host = emailSettings.SMTPServer, Port = 587, UseDefaultCredentials = false, Credentials = new NetworkCredential(emailSettings.SMTPServerEmailID, emailSettings.SMTPpassword), EnableSsl = true
     });
 }