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

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    //[GetInfoTable("index", "get")]
    public class AdminInfoPermissionsController : BaseController
    {
        public AdminInfoPermissionsController() : base("User/Admin/")
        {

        }


        [HttpGet]
        public JsonResult GetSet()
        {
            int uid = StringHelper.Format<int>(Request.QueryString["uid"]);
            int table_id = StringHelper.Format<int>(Request.QueryString["tableId"]);
            if (uid == 0)
            {
                throw new Exception("无效的uid参数！");
            }
            if (table_id==0)
            {
                throw new Exception("无效的tableid参数！");
            }
            AdminInfoPermissionsBLL bll = new AdminInfoPermissionsBLL();
            var data= bll.GetData(uid, table_id);
            return Json(data);
        }

        [HttpGet]
        public ActionResult index()
        {
            int uid = StringHelper.Format<int>(Request.QueryString["uid"]);
            if (uid == 0)
            {
                throw new Exception("无效的uid参数！");
            }
            AdminBLL adminBll = new AdminBLL();
            if(!adminBll.IsAdmin(uid))
            { 
                throw new Exception("uid值错误！");
            }
            return View();
        }

        [AjaxOnly]
        [HttpPost]
        public JsonResult SaveSet(FormCollection form)
        {
            AdminInfoPermissionsBLL bll = new AdminInfoPermissionsBLL();
            bll.Set(form);
            return Json(new TipsInfo());
        }


    }
}