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

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    public class LoginController : BaseController
    {

        [AllowAnonymous]
        [HttpGet]
        public ActionResult Index()
        {
            ViewBag.MasterHomeUrl = Url.Action("Index", "Default");
            string authenticationCode =SystemConfig.Get().AdminAuthenticationCode;
            return View((object)authenticationCode);
        }

        [ValidateAntiForgeryToken]
        [AllowAnonymous]
        [CheckMemberLock]
        [HttpPost]
        [AjaxOnly]
        public JsonResult Index(FormCollection form)
        {
            MvcControllerContext mvcContext = new MvcControllerContext();
            mvcContext.Data = form;
            TipsInfo tipsInfo = mvcContext.TipsInfo;

            if (tipsInfo.State == 0)
            {
                return Json(tipsInfo);
            }
            AdminLoginBLL BLL = new AdminLoginBLL();
            tipsInfo = BLL.Login(mvcContext);
            return Json(tipsInfo);
        }

    }
}
