using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PushPlatform.Data;
using PushPlatform.Data.Bll;
using PushPlatform.Data.Criteria;
using PushPlatform.Common.Util;
using System.Configuration;

namespace PushPlatform.Background.Areas.BackGround.Controllers
{
    public class LoginController : Controller
    {
        private BllSysUser bllSysuser = new BllSysUser();
        #region 登录页面
        public ActionResult Index()
        {
            return View();
        }
        #endregion

        #region 登录提交
        [HttpPost]
        public JsonResult Login(string loginName, string loginPwd)
        {
            JsonResult jr = new JsonResult();
            try
            {
                jr.Data = bllSysuser.Login(loginName, loginPwd);
                List<SysMenu> newli = new List<SysMenu>();
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return jr;
        }
        #endregion

        #region 退出登录
        [HttpPost]
        public JsonResult Logout()
        {
            JsonResult jr = new JsonResult();
            try
            {
                BllSysUser.ClearCurrentUser();
                jr.Data = new { Result = 1, Data = ConfigurationManager.AppSettings["backLoginUrl"] };
            }
            catch (Exception ex)
            {
                jr.Data = new { Result = 0, Msg = "异常" };
            }
            return jr;
        }
        #endregion
    }
}