/// <summary> /// Saves the specified object /// </summary> /// <param name="Object">Object to save</param> /// <returns>True if it is saved, false otherwise</returns> public bool Save(Dynamo Object) { if (Object == null) { return(false); } IAPIProperty IDProperty = Properties.FirstOrDefault(x => x is IID); if (IDProperty == null) { return(false); } object IDValue = Object[IDProperty.Name]; ClassType Item = IDValue == null ? new ClassType() : AnyFunc(IDValue.ToString()).Check(new ClassType()); if (!CanSaveFunc(Item)) { return(false); } Dynamo SubSet = Object.SubSet(Properties.Where(x => x is IReference) .Select(x => x.Name) .ToArray()); if (SubSet != null) { SubSet.CopyTo(Item); } return(SaveFunc(Item)); }
/// <summary> /// Saves an item to a specific property item /// </summary> /// <param name="ID">Model ID</param> /// <param name="PropertyName">Property name</param> /// <param name="Models">Models</param> /// <param name="MappingHolder">Mapping holder</param> /// <returns>True if it is saved, false otherwise</returns> public bool SaveProperty(string ID, MappingHolder MappingHolder, string PropertyName, IEnumerable <Dynamo> Models) { if (string.IsNullOrEmpty(ID)) { throw new ArgumentNullException(nameof(ID)); } IAPIProperty PropertyObject = Properties.FirstOrDefault(x => string.Equals(x.Name, PropertyName, StringComparison.InvariantCultureIgnoreCase)); if (PropertyObject == null) { return(false); } ClassType Object = AnyFunc(ID); if (!CanGetFunc(Object)) { return(false); } return(PropertyObject.SaveValue(MappingHolder, Object, Models)); }
/// <summary> /// Gets a specific property from an object /// </summary> /// <param name="ID">ID of the item</param> /// <param name="EmbeddedProperties">Properties to embed</param> /// <param name="Mappings">Mappings</param> /// <param name="Property">Property name</param> /// <returns>The property specified</returns> public dynamic GetProperty(string ID, MappingHolder Mappings, string Property, params string[] EmbeddedProperties) { if (string.IsNullOrEmpty(ID)) { throw new ArgumentNullException(nameof(ID)); } IAPIProperty PropertyObject = Properties.FirstOrDefault(x => string.Equals(x.Name, Property, StringComparison.InvariantCultureIgnoreCase)); if (PropertyObject == null) { return(null); } ClassType Object = AnyFunc(ID); if (!CanGetFunc(Object)) { return(null); } return(PropertyObject.GetValue(Mappings, Object)); }