public ActionResult Edit(EmailAccountManageModel model, SubmitTypeEnums submit)
 {
     if (ModelState.IsValid)
     {
         var response = _emailAccountServices.SaveEmailAccount(model);
         if (response.Success)
         {
             SetSuccessMessage(response.Message);
             switch (submit)
             {
                 case SubmitTypeEnums.Save:
                     return RedirectToAction("Index");
                 default:
                     return RedirectToAction("Edit", new { id = model.Id });
             }
         }
         SetErrorMessage(response.Message);
     }
     return View(model);
 }
        /// <summary>
        /// Save email account
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveEmailAccount(EmailAccountManageModel model)
        {
            ResponseModel response;
            var emailAccount = GetById(model.Id);
            if (emailAccount != null)
            {
                emailAccount.Email = model.Email;
                emailAccount.DisplayName = model.DisplayName;
                emailAccount.Host = model.Host;
                emailAccount.Port = model.Port;
                emailAccount.UserName = model.UserName;
                emailAccount.Password = model.Password;
                emailAccount.EnableSsl = model.EnableSsl;
                emailAccount.UseDefaultCredentials = model.UseDefaultCredentials;
                emailAccount.IsDefault = model.IsDefault;

                response = Update(emailAccount);
                return response.SetMessage(response.Success ?
                    _localizedResourceServices.T("AdminModule:::EmailAccounts:::Messages:::UpdateSuccessfully:::Update email account successfully.")
                    : _localizedResourceServices.T("AdminModule:::EmailAccounts:::Messages:::UpdateFailure:::Update email account failed. Please try again later."));
            }
            Mapper.CreateMap<EmailAccountManageModel, EmailAccount>();
            emailAccount = Mapper.Map<EmailAccountManageModel, EmailAccount>(model);
            response = Insert(emailAccount);
            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::EmailAccounts:::Messages:::CreateSuccessfully:::Create email account successfully.")
                : _localizedResourceServices.T("AdminModule:::EmailAccounts:::Messages:::CreateFailure:::Create email account failed. Please try again later."));
        }