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

namespace PageAdmin.Web.Areas.Admin.Controllers
{

    public class MemberGroupInfoPermissionsController : BaseController
    {
        public MemberGroupInfoPermissionsController() : base("User/MemberGroup/")
        {

        }

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

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

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


    }
}