private IList <Resource> GetAlowedResourceList(decimal roleId) { string extension = roleId.ToString(); IList <Resource> list = new List <Resource>(); if (!SessionHelper.HasSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension)) { list = athorizeRep.GetAccessAllowed(roleId); if (list != null && list.Count > 0) { SessionHelper.SaveSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension, list); } else { SessionHelper.ClearSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension); } } object obj = SessionHelper.GetSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension); if (obj != null) { list = (IList <Resource>)obj; } return(list); }
public bool HasAccessToResource(string username, string resourceKey) { try { BUser busUser = new BUser(); User user = busUser.GetByUsername(username); if (user == null || user.Role == null || user.Role.ID == 0) { return(false); } IList <Resource> list = authorizeRep.GetAccessAllowed(user.Role.ID); return(list.Where(x => x.ResourceID.ToLower().Equals(resourceKey.ToLower())).Count() > 0); } catch (Exception ex) { LogException(ex); throw ex; } }