public bool HasAccess(int roleId, string controller, string action) /*=> true;*/ { var roleName = _roleRepository.GetRoleNameByRoleId(roleId); if (roleName == ImportantNames.AdminNormalTitle()) { return(true); } var userAccess = TableNoTracking.Where(a => a.RoleId == roleId).ToList(); foreach (var item in userAccess) { if (item.Controller.ToUpper() == controller.ToUpper() + ImportantNames.ControllerName()) { var actions = item.Actions == null ? null : JsonConvert.DeserializeObject <List <string> >(item.Actions); if (actions != null && actions.Contains(action)) { return(true); } } } return(false); }
public bool HasAccess(int role, IDictionary <string, string> path) { var roleName = _roleRepository.GetRoleNameByRoleId(role); if (roleName == ImportantNames.AdminNormalTitle()) { return(true); } var userAccess = TableNoTracking.Include(a => a.Roles).Where(a => a.Roles.Id == role).ToList(); foreach (var item in userAccess) { if (item.Controller.ToUpper() == path["controller"].ToUpper() + ImportantNames.ControllerName()) { var actions = item.Actions == null ? null : JsonConvert.DeserializeObject <List <string> >(item.Actions); if (actions != null && actions.Contains(path["action"])) { return(true); } } } return(false); }