Ejemplo n.º 1
0
        public PositionAccessNodeVM(int accessRuleId, int positionId, AccessRuleDataService accessRuleDataService, PositionAccessRuleDataService positionAccessRuleDataService, AccessType access)
            : base(access)
        {
            var accessRule = accessRuleDataService.GetSingle(accessRuleId);
            Title = Common.Properties.Resources.ResourceManager.GetString(accessRule.Name);
            Id = accessRule.Id;
            ParentId =accessRule.Parent != null? accessRule.Parent.Id : -1;
            foreach (var child in accessRule.Children)
            {
                ChildNodes.Add(new PositionAccessNodeVM(child.Id,positionId,accessRuleDataService, positionAccessRuleDataService, Access));
            }

            var positionAccessRule = positionAccessRuleDataService.GetSingle(positionId, accessRuleId);
            if (positionAccessRule != null)
            {
                if (positionAccessRule.Type != null) 
                    PositionAccess = (AccessType) positionAccessRule.Type;
            }
        }
Ejemplo n.º 2
0
        public UserAccessNodeVM(int accessRuleId, int userId, AccessRuleDataService accessRuleDataService, UserAccessRuleDataService userAccessRuleDataService, List<Tuple<int, AccessType>> ruleAccessList, AccessType access)
            : base(access)
        {
            var accessRule = accessRuleDataService.GetSingle(accessRuleId);
            Title = Common.Properties.Resources.ResourceManager.GetString(accessRule.Name);
            Id = accessRule.Id;
            ParentId = accessRule.Parent != null ? accessRule.Parent.Id : -1;
            foreach (var child in accessRule.Children)
            {
                ChildNodes.Add(new UserAccessNodeVM(child.Id, userId, accessRuleDataService, userAccessRuleDataService, ruleAccessList, Access));
            }

            var userAccessRule = userAccessRuleDataService.GetSingle(userId, accessRuleId);
            if (userAccessRule != null)
            {
                if (userAccessRule.Type != null) UserAccess = (AccessType)userAccessRule.Type;
            }

            if(!ruleAccessList.Any()) return;
            foreach (Tuple<int, AccessType> tuple in ruleAccessList.Where(item => item.Item1 == accessRuleId))
            {
                PositionAccess |= tuple.Item2;
            }
        }
Ejemplo n.º 3
0
 public static AccessRule CreateNew(AccessRuleDataService dataService)
 {
     int id = dataService.AddModel(new AccessRule { Name = "جدید", Code = string.Empty });
     return dataService.GetSingle(id);
 }