using PageAdmin.Utils;
using System.Collections.Specialized;

namespace PageAdmin.Web.Areas.Admin.Controllers

{
    public class ApiAdminController : DefaultBaseController
    {
        public ApiAdminController() : base("pa_api_admin", "System/Configure/")
        {
            base.MvcContext.ListOrder = "id desc";
            base.AddExecuting = SetUserConfig;
            base.EditExecuting = SetUserConfig;
        }

        private void SetUserConfig()
        {
            NameValueCollection form = base.MvcContext.Data;
            var authorizeConfig = new
            {
                Uids = form["uids"],
                MemberGroupIds = form["memberGroupIds"],
                RoleIds = form["roleIds"],
                DepartmentIds = form["departmentIds"]
            };
            form["authorizeConfig"] = JsonHelper.JsonParse(authorizeConfig);
        }

    }
}