public ActionResult System_email(string act, string ctrl, string type_act, string type)
        {
            var           email_view    = new Web.Areas.Admin.ViewModels.Email_view();
            WebInfoModels webInfoModels = new WebInfoModels();

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "system_email";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminGeneral";
            }

            if (string.IsNullOrEmpty(type_act))
            {
                type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View;
            }

            try
            {
                email_view.SmtpHost = webInfoModels.GetContent(CommonGlobal.SmtpHost);
                email_view.SmtpPort = webInfoModels.GetContent(CommonGlobal.SmtpPort);
                email_view.SmtpUser = webInfoModels.GetContent(CommonGlobal.SmtpUser);
                email_view.SmtpPass = webInfoModels.GetContent(CommonGlobal.SmtpPass);
                email_view.Email    = webInfoModels.GetContent(CommonGlobal.Email);
            }
            catch (Exception)
            {
                email_view.Message = "Đã xảy ra lỗi trong quá trình lấy dữ liệu.";
            }

            ////Link tab
            StringBuilder sb = new StringBuilder();

            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "system_config", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Cấu hình chung</span></a></li>");
            sb.Append("<li class=\"active\"><a href=\"#\"><span>Cấu hình email</span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "footer", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Footer</span></a></li>");
            email_view.Html_link_tab = sb.ToString();

            ////action
            email_view.Type              = type;
            email_view.Type_act          = type_act;
            email_view.Act               = act;
            email_view.Ctrl              = ctrl;
            email_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            email_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/system_email", email_view));
        }
        public ActionResult System_email(FormCollection collection)
        {
            WebInfoModels webInfoModels = new WebInfoModels();
            var           email_view    = new Web.Areas.Admin.ViewModels.Email_view();

            this.TryUpdateModel(email_view);

            ////action
            email_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            email_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            ////Link tab
            StringBuilder sb = new StringBuilder();

            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "system_config", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Cấu hình chung</span></a></li>");
            sb.Append("<li class=\"active\"><a href=\"#\"><span>Cấu hình email</span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "footer", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Footer</span></a></li>");
            email_view.Html_link_tab = sb.ToString();

            if (string.IsNullOrEmpty(email_view.SmtpHost))
            {
                email_view.Message = "Bạn cần nhập Smtp Host";
                return(this.PartialView("../control/system_email", email_view));
            }

            if (string.IsNullOrEmpty(email_view.SmtpPort))
            {
                email_view.Message = "Bạn cần nhập Smtp Port";
                return(this.PartialView("../control/system_email", email_view));
            }

            if (string.IsNullOrEmpty(email_view.SmtpUser))
            {
                email_view.Message = "Bạn cần nhập Smtp User";
                return(this.PartialView("../control/system_email", email_view));
            }

            if (string.IsNullOrEmpty(email_view.SmtpPass))
            {
                email_view.Message = "Bạn cần nhập Smtp Pass";
                return(this.PartialView("../control/system_email", email_view));
            }

            if (string.IsNullOrEmpty(email_view.Email))
            {
                email_view.Message = "Bạn cần nhập Email";
                return(this.PartialView("../control/system_email", email_view));
            }

            try
            {
                if (email_view.Type_act == CommonGlobal.Edit)
                {
                    ////SMTP Host
                    C_WebInfo objSMTPHost = new C_WebInfo();
                    objSMTPHost.GeneralName    = CommonGlobal.SmtpHost;
                    objSMTPHost.GeneralContent = email_view.SmtpHost;
                    objSMTPHost.Datemodified   = DateTime.Now;
                    webInfoModels.Update(objSMTPHost);

                    ////SMTP Port
                    C_WebInfo objSMTPPort = new C_WebInfo();
                    objSMTPPort.GeneralName    = CommonGlobal.SmtpPort;
                    objSMTPPort.GeneralContent = email_view.SmtpPort;
                    objSMTPPort.Datemodified   = DateTime.Now;
                    webInfoModels.Update(objSMTPPort);

                    ////SMTP User
                    C_WebInfo objSMTPUser = new C_WebInfo();
                    objSMTPUser.GeneralName    = CommonGlobal.SmtpUser;
                    objSMTPUser.GeneralContent = email_view.SmtpUser;
                    objSMTPUser.Datemodified   = DateTime.Now;
                    webInfoModels.Update(objSMTPUser);

                    ////SMTP Pass
                    C_WebInfo objSMTPPass = new C_WebInfo();
                    objSMTPPass.GeneralName    = CommonGlobal.SmtpPass;
                    objSMTPPass.GeneralContent = email_view.SmtpPass;
                    objSMTPPass.Datemodified   = DateTime.Now;
                    webInfoModels.Update(objSMTPPass);

                    ////Email
                    C_WebInfo objEmail = new C_WebInfo();
                    objEmail.GeneralName    = CommonGlobal.Email;
                    objEmail.GeneralContent = email_view.Email;
                    objEmail.Datemodified   = DateTime.Now;
                    webInfoModels.Update(objEmail);
                }
            }
            catch (Exception)
            {
                email_view.Message = "Đã xảy ra lỗi cập nhật dữ liệu.";
            }

            email_view.Message = "Cập nhật thành công.";

            return(this.PartialView("../control/system_email", email_view));
        }