Beispiel #1
0
        /// <summary>
        /// check the access of all user's roles
        /// </summary>
        /// <param name="EntityName"></param>
        /// <param name="RelatedSerice"></param>
        /// <returns></returns>
        public static bool IsValidAccessToRight(string RightName, string UserRoles)
        {
            string ASCService = string.Format("{0}_Right_{1}", "ASC", RightName);

            if (HttpContext.Current.Session[ASCService] != null)
            {
                return((bool)HttpContext.Current.Session[ASCService]);
            }
            else
            {
                using (AccessEntities mympo = new AccessEntities())
                {
                    string roles = UserRoles;
                    if (string.IsNullOrEmpty(roles))
                    {
                        return(false);
                    }
                    int result = mympo.Right_ValidByName(roles, RightName).FirstOrDefault().Value.ToInt32();

                    HttpContext.Current.Session[ASCService] = result <= 0 ? false : true;

                    return((bool)HttpContext.Current.Session[ASCService]);
                }
            }
        }