Beispiel #1
0
        public ActionResult Create(ServerMailSettingViewModel serverMail, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    base.ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(base.View(serverMail));
                }
                else
                {
                    ServerMailSetting serverMailSetting = Mapper.Map <ServerMailSettingViewModel, ServerMailSetting>(serverMail);
                    this._mailSettingService.Create(serverMailSetting);
                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.ServerMailSetting)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("MailSetting.Create: ", exception.Message));
                return(base.View(serverMail));
            }
            return(action);
        }
Beispiel #2
0
        public ActionResult SendContact(string name, string email, string content)
        {
            ActionResult actionResult;

            try
            {
                if (!base.Request.IsAjaxRequest())
                {
                    return(base.Json(new { succes = false, message = "Liên hệ chưa gửi được, vui lòng thử lại." }));
                }
                else
                {
                    ServerMailSetting serverMailSetting = this._mailSettingService.Get((ServerMailSetting x) => x.Status == 1, false);
                    string            str  = this._systemSettingService.Get((SystemSetting x) => x.Status == 1, false).Email;
                    string            str1 = "Thông tin liên hệ";
                    string            str2 = string.Concat("", "Người gửi: ", name, "<br>");
                    str2 = string.Concat(str2, string.Concat("E-mail: ", email), "<br>");
                    str2 = string.Concat(str2, content, "<br>");
                    SendMail sendMail = new SendMail();
                    sendMail.InitMail(serverMailSetting.FromAddress, serverMailSetting.SmtpClient, serverMailSetting.UserID, serverMailSetting.Password, serverMailSetting.SMTPPort, serverMailSetting.EnableSSL);
                    sendMail.SendToMail("Email", str, new string[] { str1, str2 });
                    actionResult = base.Json(new { success = true, message = "Gửi liên hệ thành công, chúng tôi sẽ liên lạc với bạn ngay khi có thể." });
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            return(actionResult);
        }