Beispiel #1
0
        public IEnumerable <string> GetAvailableFields(
            FieldPropertiesForEntityType forEntityType,
            Guid?roleId,
            Guid?userId)
        {
            var hiddenAccessType = FieldPropertiesAccessType.Hidden.ToString().ToLowerFirstLetter();
            var fieldProperties  = GetFor(forEntityType.ToString(), roleId, userId)
                                   .Where(x => !x.isHidden);

            foreach (var prop in fieldProperties)
            {
                bool hasAccess = prop.AccessTypes.Any(x => x.Value != hiddenAccessType);
                if (hasAccess)
                {
                    yield return(prop.FieldName);
                }
            }
        }
Beispiel #2
0
        public IEnumerable <string> GetReadOnlyFields(
            FieldPropertiesForEntityType forEntityType,
            string stateName,
            Guid?roleId,
            Guid?userId)
        {
            var editAccessType  = FieldPropertiesAccessType.Edit.ToString().ToLowerFirstLetter();
            var fieldProperties = GetFor(forEntityType.ToString(), roleId, userId);

            foreach (var prop in fieldProperties)
            {
                bool isReadOnly = true;
                if (prop.AccessTypes.TryGetValue(stateName, out string accessType))
                {
                    isReadOnly = accessType != editAccessType;
                }
                if (isReadOnly)
                {
                    yield return(prop.FieldName);
                }
            }
        }