public override void Add(DataSourceContext context, JToken data) { var schema = GetAlpaca(context, true, false, false)["schema"] as JObject; if (DotNetNukeContext.Current.Application.Version.Major <= 7) { var sett = new PortalSettingInfo7(); sett.PortalID = context.PortalId; sett.CultureCode = context.CurrentCultureCode; sett.CreatedByUserID = context.UserId; sett.CreatedOnDate = DateTime.Now; sett.LastModifiedByUserID = context.UserId; sett.LastModifiedOnDate = DateTime.Now; if (HasProperty(schema, "", "SettingName")) { sett.SettingName = data["SettingName"]?.ToString() ?? ""; } if (HasProperty(schema, "", "SettingValue")) { sett.SettingValue = data["SettingValue"]?.ToString() ?? ""; } if (HasProperty(schema, "", "CultureCode")) { sett.CultureCode = data["CultureCode"]?.ToString() ?? ""; } Add(sett); } else { var sett = new PortalSettingInfo(); sett.PortalID = context.PortalId; sett.CultureCode = context.CurrentCultureCode; sett.CreatedByUserID = context.UserId; sett.CreatedOnDate = DateTime.Now; sett.LastModifiedByUserID = context.UserId; sett.LastModifiedOnDate = DateTime.Now; if (HasProperty(schema, "", "SettingName")) { sett.SettingName = data["SettingName"]?.ToString() ?? ""; } if (HasProperty(schema, "", "SettingValue")) { sett.SettingValue = data["SettingValue"]?.ToString() ?? ""; } if (HasProperty(schema, "", "CultureCode")) { sett.CultureCode = data["CultureCode"]?.ToString() ?? ""; if (sett.CultureCode == "") { sett.CultureCode = null; } } Add(sett); } }
public PortalSettingInfo7 Update(PortalSettingInfo7 setting) { using (IDataContext ctx = DataContext.Instance()) { ctx.Execute(CommandType.Text, "UPDATE {databaseOwner}[{objectQualifier}PortalSettings] SET SettingName = @1, SettingValue = @3, CultureCode = @2 WHERE PortalID = @0 AND SettingName = @1 AND CultureCode = @2 ", setting.PortalID, setting.SettingName, setting.CultureCode, setting.SettingValue); } return(setting); }
public PortalSettingInfo7 Add(PortalSettingInfo7 setting) { using (IDataContext ctx = DataContext.Instance()) { ctx.Execute(CommandType.Text, "INSERT INTO {databaseOwner}[{objectQualifier}PortalSettings] " + "(PortalID, SettingName, SettingValue, CreatedByUserID, CreatedOnDate, LastModifiedByUserID, LastModifiedOnDate, CultureCode) " + "VALUES (@0, @1, @2, @3, @4, @5, @6, @7)", setting.PortalID, setting.SettingName, setting.SettingValue, setting.CreatedByUserID, setting.CreatedOnDate, setting.LastModifiedByUserID, setting.LastModifiedOnDate, setting.CultureCode); } return(setting); }
public override IDataItem Get(DataSourceContext context, string id) { IDataItem data = null; PortalSettingInfoBase item; if (DotNetNukeContext.Current.Application.Version.Major <= 7) { var ps = new PortalSettingInfo7(id); item = GetByPrimaryKey(ps.PortalID, ps.SettingName, ps.CultureCode); } else { item = GetById <PortalSettingInfo>(Int32.Parse(id)); } data = ToData(item); return(data); }