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

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    [CurrentSite]
    public class DefaultController : BaseController
    {


        //默认首页
        [HttpGet]
        [Default]
        public ActionResult Index()
        {
           return View();
        }

        /// <summary>
        /// 后台首页
        /// </summary>
        /// <returns></returns>
        [CurrentUserInfo]
        [HttpGet]
        [Home]
        public ActionResult Home()
        {
            return View();
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Exit()
        {
            LoginingUseBLL loginUserBll = new LoginingUseBLL();
            loginUserBll.Exit();
            return RedirectToAction("Index", "Login");
        }

        [AjaxOnly]
        [HttpPost]
        public JsonResult RestartApplication()
        {
            SysHelper.RestartApplication();
            TipsInfo tipsInfo = new TipsInfo();
            return Json(tipsInfo);
        }

        [AjaxOnly]
        [HttpGet]
        public JsonResult GetWebNotice()
        {
            int number = StringHelper.Format<int>(Request.QueryString["number"]);
            if(number==0)
            {
                number =8;
            }
            NoticeBLL noticeBLL = new NoticeBLL();
            return Json(noticeBLL.GetAdminNotice(number));
        }

        [AjaxOnly]
        [HttpGet]
        public string HasUpgrade()
        {
            OnlineUpgradeBLL onlineUpgradeBLL = new OnlineUpgradeBLL();
            string upgradeData = onlineUpgradeBLL.GetUpgradeList("check");
            bool upgrade = onlineUpgradeBLL.HasUpgrade;
            return upgrade.ToString();
        }

    }
}
