/// <summary> /// Add a new Value /// </summary> internal EavValue AddValue(Entity entity, int attributeId, string value, bool autoSave = true) { var changeId = Context.Versioning.GetChangeLogId(); var newValue = new EavValue { AttributeID = attributeId, Entity = entity, Value = value, ChangeLogIDCreated = changeId }; Context.SqlDb.AddToValues(newValue); if (autoSave) Context.SqlDb.SaveChanges(); return newValue; }
/// <summary> /// Append an element to this. The element will have the value of the EavValue. File and page references /// can optionally be resolved. /// </summary> public static void AppendValue(this XElement element, XName name, EavValue value, ResourceReferenceExport resourceReferenceOption) { if (value == null) { element.Append(name, "[]"); } else if (value.Value == null) { element.Append(name, "[]"); } else if (resourceReferenceOption.IsResolve()) { element.Append(name, value.ResolveValueReference()); } else if (value.Value == string.Empty) { element.Append(name, "[\"\"]"); } else { element.Append(name, value.Value); } }
/// <summary> /// Update a Value /// </summary> internal void UpdateValue(EavValue currentValue, string value, int changeId, bool autoSave = true) { // only if value has changed if (currentValue.Value.Equals(value)) return; currentValue.Value = value; currentValue.ChangeLogIDModified = changeId; currentValue.ChangeLogIDDeleted = null; if (autoSave) Context.SqlDb.SaveChanges(); }