using PageAdmin.Utils;
using PageAdmin.Web.Filter;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.Admin.Controllers
{

    public class MemberSetController : BaseController
    {
        public MemberSetController():base("User")
        {
         
        }

        //[GetCanRegMemberGroupList]
        [HttpGet]
        public virtual ActionResult Index()
        {
            ViewBag.LoginConfig = JsonHelper.JsonParse(XmlHelper.AllNodeValue("configuration", "/Config/MemberLogin.config"));
            ViewBag.RegConfig = JsonHelper.JsonParse(XmlHelper.AllNodeValue("configuration", "/Config/MemberReg.config"));
            ViewBag.FindPassConfig = JsonHelper.JsonParse(XmlHelper.AllNodeValue("configuration", "/Config/MemberFindPassword.config"));
            ViewBag.MemberCenterConfig = JsonHelper.JsonParse(XmlHelper.AllNodeValue("configuration", "/Config/MemberCenter.config"));
            ViewBag.AdminCenterConfig = JsonHelper.JsonParse(XmlHelper.AllNodeValue("configuration", "/Config/AdminCenter.config"));
            return View();
        }

        [ValidateAntiForgeryToken]
        [ValidateInput(false)]
        [AjaxOnly]
        [HttpPost]
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public JsonResult Update(FormCollection form)
        {
            TipsInfo tipsInfo = new TipsInfo();
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/MemberLogin.config", "Login_");
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/MemberReg.config", "Reg_");
            if(form["FindPassword_FindByEmail"]==null)
            {
                form["FindPassword_FindByEmail"] = "0";
            }
            if (form["FindPassword_FindByMobile"] == null)
            {
                form["FindPassword_FindByMobile"] = "0";
            }
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/MemberFindPassword.config", "FindPassword_");
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/MemberCenter.config", "MemberCenter_");
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/AdminCenter.config", "AdminCenter_");
            return Json(tipsInfo);
        }


        [HttpGet]
        public ActionResult RegAgreement()
        {
           string content = XmlHelper.NodeValue("/configuration/content", "/Config/MemberRegAgreement.config");
           return View((object)content);
        }

        [ValidateAntiForgeryToken]
        [ValidateInput(false)]
        [HttpPost]
        [AjaxOnly]
        public ActionResult RegAgreement(FormCollection form)
        {
            TipsInfo tipsInfo = new TipsInfo();
            XmlHelper.UpdateNodeValue("configuration", form, "/Config/MemberRegAgreement.config");
            return Json(tipsInfo);
        }

    }
}