/// <summary> /// Adds Related data (a.k.a Additional Data). /// Related data is data that is supportive to the Core data of datasource. Eg Categories, Enums, etc /// </summary> /// <param name="context">The context.</param> /// <param name="scope">The scope.</param> /// <param name="key">The key.</param> /// <param name="data">The data.</param> public virtual void AddData(DataSourceContext context, string scope, string key, JToken data) { string scopeStorage = AdditionalDataUtils.GetScope(scope, context.PortalId, context.TabId, GetModuleId(context), context.TabModuleId); AdditionalDataController ctrl = new AdditionalDataController(); var additionalData = new AdditionalDataInfo() { Scope = scopeStorage, DataKey = key, Json = data.ToString(), CreatedByUserId = context.UserId, CreatedOnDate = DateTime.Now, LastModifiedByUserId = context.UserId, LastModifiedOnDate = DateTime.Now, }; ctrl.AddData(additionalData); }
/// <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); }