Beispiel #1
0
    public static bool HasPermissionPage(string permission)
    {
        bool    bFound = false;
        decimal result;

        try
        {
            if (decimal.TryParse(HttpContext.Current.Session["UserID"].ToString(), out result))
            {
                if (HttpContext.Current.Session["UserRole"] == null)
                {
                    HisUser user = new HisUser(result, true);
                    HttpContext.Current.Session["UserRole"] = user.GetUserPermissions(true);
                    bFound = user.HasPermission(permission, (List <Permission>)HttpContext.Current.Session["UserRole"]);
                }
                else
                {
                    HisUser user = new HisUser(result);
                    bFound = user.HasPermission(permission, (List <Permission>)HttpContext.Current.Session["UserRole"]);
                }
            }
            //Check if the requesting user has the specified application permission...
        }
        catch { }
        return(bFound);
    }
Beispiel #2
0
    public static bool HasPermission(this ControllerBase controller, string permission, decimal _userId)
    {
        bool bFound = false;

        try
        {
            //Check if the requesting user has the specified application permission...
            bFound = new HisUser(_userId).HasPermission(permission);
        }
        catch { }
        return(bFound);
    }