public void UpdateData(AdditionalDataInfo data) { OpenContentVersion ver = new OpenContentVersion() { Json = data.Json.ToJObject("UpdateContent"), CreatedByUserId = data.CreatedByUserId, CreatedOnDate = data.CreatedOnDate, LastModifiedByUserId = data.LastModifiedByUserId, LastModifiedOnDate = data.LastModifiedOnDate }; var versions = data.Versions; if (versions.Count == 0 || versions[0].Json.ToString() != data.Json) { versions.Insert(0, ver); if (versions.Count > OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalSettings.Current.PortalId).GetMaxVersions()) { versions.RemoveAt(versions.Count - 1); } data.Versions = versions; } using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <AdditionalDataInfo>(); rep.Update(data); } }
public void DeleteData(AdditionalDataInfo data) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <AdditionalDataInfo>(); rep.Delete(data); } }
public AdditionalDataInfo GetData(string scope, string key) { AdditionalDataInfo content = null; using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <AdditionalDataInfo>(); var lst = rep.Get(scope); if (lst != null) { content = lst.SingleOrDefault(d => d.DataKey == key); } } return(content); }
public AdditionalDataInfo GetData(string scope, string key) { AdditionalDataInfo content = null; using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <AdditionalDataInfo>(); var lst = rep.Get(scope); if (lst != null) { content = lst.SingleOrDefault(d => string.Equals(d.DataKey, key, StringComparison.InvariantCultureIgnoreCase)); } } return(content); }
public void AddData(AdditionalDataInfo data) { OpenContentVersion ver = new OpenContentVersion() { Json = data.Json.ToJObject("Adding AdditionalData"), CreatedByUserId = data.CreatedByUserId, CreatedOnDate = data.CreatedOnDate, LastModifiedByUserId = data.LastModifiedByUserId, LastModifiedOnDate = data.LastModifiedOnDate }; var versions = new List <OpenContentVersion>(); versions.Add(ver); data.Versions = versions; using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <AdditionalDataInfo>(); rep.Insert(data); } }
private static void AddVersions(JObject json, AdditionalDataInfo data) { if (!string.IsNullOrEmpty(data.VersionsJson)) { var verLst = new JArray(); foreach (var item in data.Versions) { var ver = new JObject(); ver["text"] = item.CreatedOnDate.ToShortDateString() + " " + item.CreatedOnDate.ToShortTimeString(); if (verLst.Count == 0) // first { ver["text"] = ver["text"] + " ( current )"; } ver["ticks"] = item.CreatedOnDate.Ticks.ToString(); verLst.Add(ver); } json["versions"] = verLst; //json["versions"] = JArray.Parse(struc.VersionsJson); } }