private static IDataItem ToData(PortalSettingInfoBase setting)
        {
            var item = new DefaultDataItem()
            {
                Id    = setting.Id(),
                Title = $"{setting.SettingName}",
                Data  = JObject.FromObject(new
                {
                    Id = setting.Id(),
                    setting.PortalID,
                    setting.SettingName,
                    setting.SettingValue,
                    setting.CultureCode,
                    //setting.CreatedByUserID,
                    //setting.CreatedOnDate,
                    //setting.LastModifiedByUserID,
                    //setting.LastModifiedOnDate
                }),
                CreatedByUserId      = setting.CreatedByUserID.GetValueOrDefault(),
                LastModifiedByUserId = setting.LastModifiedByUserID.GetValueOrDefault(),
                LastModifiedOnDate   = setting.LastModifiedOnDate.GetValueOrDefault(),
                CreatedOnDate        = setting.CreatedOnDate.GetValueOrDefault(),
                Item = setting
            };

            return(item);
        }
        public override IDataItems GetAll(DataSourceContext context, Select selectQuery)
        {
            int AdminTabId = PortalSettings.Current.AdminTabId;
            var tabs       = TabController.GetTabsBySortOrder(context.PortalId).Where(t => t.ParentId != AdminTabId && !t.IsSuperTab);

            tabs = tabs.Where(t => Navigation.CanShowTab(t, false, true, false));
            int total = tabs.Count();

            if (selectQuery != null)
            {
                var tabName = selectQuery.Query.FilterRules.FirstOrDefault(f => f.Field == "TabName");
                if (tabName != null)
                {
                    tabs = tabs.Where(t => t.TabName.ToLower().Contains(tabName.Value.AsString.ToLower()));
                }
                tabs = tabs.Skip(selectQuery.PageIndex * selectQuery.PageSize).Take(selectQuery.PageSize).ToList();
            }
            var dataList = new List <IDataItem>();

            foreach (var tab in tabs)
            {
                var item = new DefaultDataItem()
                {
                    Id    = tab.TabID.ToString(),
                    Title = tab.TabName,
                    Data  = JObject.FromObject(new
                    {
                        tab.TabName,
                        tab.TabID,
                        tab.Title,
                        tab.Description,
                    }),
                    CreatedByUserId      = tab.CreatedByUserID,
                    LastModifiedByUserId = tab.LastModifiedByUserID,
                    LastModifiedOnDate   = tab.LastModifiedOnDate,
                    CreatedOnDate        = tab.CreatedOnDate,
                    Item = tab
                };
                item.Data["Settings"] = new JObject();
                item.Data["Head"]     = new JObject();
                foreach (string key in tab.TabSettings.Keys)
                {
                    if (key.StartsWith("og:"))
                    {
                        item.Data["Head"][key] = tab.TabSettings[key].ToString();
                    }
                    else
                    {
                        item.Data["Settings"][key] = tab.TabSettings[key].ToString();
                    }
                }
                dataList.Add(item);
            }
            return(new DefaultDataItems()
            {
                Items = dataList,
                Total = total,
                //DebugInfo =
            });
        }
        private static IDataItem ToData(UserInfo user)
        {
            var item = new DefaultDataItem()
            {
                Id    = user.UserID.ToString(),
                Title = user.DisplayName,
                Data  = JObject.FromObject(new
                {
                    user.UserID,
                    user.DisplayName,
                    user.Username,
                    user.FirstName,
                    user.LastName,
                    user.Email,
                    user.Membership.Approved,
                    user.Membership.LockedOut,
                    user.IsDeleted
                }),
                CreatedByUserId      = user.CreatedByUserID,
                LastModifiedByUserId = user.LastModifiedByUserID,
                LastModifiedOnDate   = user.LastModifiedOnDate,
                CreatedOnDate        = user.CreatedOnDate,
                Item = user
            };

            item.Data["Profile"] = new JObject();
            foreach (ProfilePropertyDefinition def in user.Profile.ProfileProperties)
            {
                //ProfilePropertyAccess.GetRichValue(def, )
                if (def.PropertyName.ToLower() == "photo")
                {
                    item.Data["Profile"]["PhotoURL"]       = user.Profile.PhotoURL;
                    item.Data["Profile"][def.PropertyName] = def.PropertyValue;
                }
                else
                {
                    item.Data["Profile"][def.PropertyName] = def.PropertyValue;
                }
            }
            var roles = new JArray();

            item.Data["Roles"] = roles;
            foreach (var role in user.Roles)
            {
                if (role != REGISTERED_USERS)
                {
                    roles.Add(role);
                }
            }
            return(item);
        }
        /// <summary>
        /// Gets additional/related data of a datasource.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="scope">The Scope. (portal, tab, module, tabmodule)</param>
        /// <param name="key">The unique key in the scope</param>
        /// <returns></returns>
        public virtual IDataItem GetData(DataSourceContext context, string scope, string key)
        {
            string scopeStorage = AdditionalDataUtils.GetScope(scope, context.PortalId, context.TabId, GetModuleId(context), context.TabModuleId);
            var    dc           = new AdditionalDataController();
            var    data         = dc.GetData(scopeStorage, key);

            if (data != null)
            {
                var dataItem = new DefaultDataItem
                {
                    Data            = data.Json.ToJObject("GetContent " + scope + "/" + key),
                    CreatedByUserId = data.CreatedByUserId,
                    Item            = data
                };
                LogContext.Log(context.ActiveModuleId, "Get Data", "Result", dataItem);
                return(dataItem);
            }
            return(null);
        }