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

namespace PageAdmin.Web.Areas.E.Controllers
{

    /// <summary>
    /// 手机验证码
    /// </summary>
    public class SmsCodeController : Controller
    {


        [ValidateAntiForgeryToken]
        [AjaxOnly]
        [HttpPost]
        public JsonResult Send(FormCollection form)
        {
            string mobile = form["mobile"];
            SmsCodeBLL smsCodeBLL = new SmsCodeBLL();
            var tipsInfo = smsCodeBLL.Send(mobile);
            return Json(tipsInfo);
        }


        [AjaxOnly]
        [HttpPost]
        public JsonResult Validate(FormCollection form)
        {
            string validateName = StringHelper.Format<string>(form["_validateName"]);
            string code = StringHelper.Format<string>(form[validateName]);
            string mobile = form["mobile"];
            SmsCodeBLL smsCodeBLL = new SmsCodeBLL();
            var tipsInfo = smsCodeBLL.Validate(mobile, code);
            return Json(tipsInfo);
        }


    }
}