using PageAdmin.BLL;
using PageAdmin.Common;
using PageAdmin.Utils;
using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.Member.Controllers
{
    /// <summary>
    /// 后台首页
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class SecurityAttribute : ActionFilterAttribute
    {

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CurrentUser currentUser = filterContext.Controller.ViewBag.CurrentUser;
            MemberBLL memberBll = new MemberBLL();
            dynamic data = memberBll.GetData(currentUser.Uid);
            filterContext.Controller.ViewBag.MemberData = JsonHelper.JsonParse(data);
            MemberGroupBLL memberGroupBLL = new MemberGroupBLL();
            filterContext.Controller.ViewBag.MemberGroupName = memberGroupBLL.GetName(currentUser.MemberGroupId);
            DepartmentBLL departmentBLL = new DepartmentBLL();
            string departmentName = departmentBLL.GetName(currentUser.DepartmentId);
            filterContext.Controller.ViewBag.DepartmentName = departmentName;
        }


    }
}
