/// <summary> /// Updates Salesforce object. /// </summary> /// <param name="values">Object values.</param> /// <returns>Operation result.</returns> public bool UpdateObject <T>(Dictionary <string, IConvertible> values) where T : SalesforceEntityBase { bool result = false; if (CheckConnected()) { if (values == null) { throw (new ArgumentNullException("values")); } if (values.Count > 0) { if (values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = _binding.update ( new sObject[] { Constructor.ConstructSObject(typeof(T).Name, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(Errors.ERR_ID_FIELD_IS_NOT_SET)); } } else { throw (new InvalidOperationException(Errors.ERR_FIELDS_ARE_EMPTY)); } } return(result); }
/// <summary> /// Updates Salesforce object. /// </summary> /// <param name="entity">Entity.</param> /// <returns>Operation result.</returns> public bool UpdateObject(SalesforceEntity entity) { bool result = false; if (this.CheckConnected()) { // Check parameters if (entity == null) { throw (new ArgumentNullException("entity")); } // Extract current values of entity Dictionary <string, IConvertible> values = Extractor.ExtractFieldValues ( entity, new ExtractionOptions() { ExcludeUpdateIgnored = true } ); // Values should not be empty if (values.Count > 0) { // Construct Salesforce object if (values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = this._binding.update ( new sObject[] { Constructor.ConstructSObject(entity.GetType().Name, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(ERR_ID_FIELD_IS_NOT_SET)); } } else { throw (new InvalidOperationException(ERR_FIELDS_ARE_EMPTY)); } } return(result); }
/// <summary> /// Updates Salesforce object. /// </summary> /// <param name="objectTypeName">Object type name.</param> /// <param name="values">Object values.</param> /// <returns>Operation result.</returns> public bool UpdateObject(string objectTypeName, Dictionary <string, IConvertible> values) { bool result = false; if (this.CheckConnected()) { // Check parameters if (String.IsNullOrEmpty(objectTypeName)) { throw (new ArgumentNullException("objectTypeName")); } if (values == null) { throw (new ArgumentNullException("values")); } // Values should not be empty if (values.Count > 0) { // Construct Salesforce object if (values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = this._binding.update ( new sObject[] { Constructor.ConstructSObject(objectTypeName, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(ERR_ID_FIELD_IS_NOT_SET)); } } else { throw (new InvalidOperationException(ERR_FIELDS_ARE_EMPTY)); } } return(result); }
/// <summary> /// Creates Salesforce object. /// </summary> /// <param name="entity">Entity.</param> /// <returns>Operation result.</returns> public bool CreateObject(SalesforceEntityBase entity) { bool result = false; if (CheckConnected()) { if (entity == null) { throw (new ArgumentNullException("entity")); } Dictionary <string, IConvertible> values = Extractor.ExtractFieldValues ( entity, new ExtractionOptions() { ExcludeCreateIgnored = true } ); if (values.Count > 0) { if (!values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = _binding.create ( new sObject[] { Constructor.ConstructSObject(entity.GetType().Name, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(Errors.ERR_ID_FIELD_IS_AUTOGENERATED)); } } else { throw (new InvalidOperationException(Errors.ERR_FIELDS_ARE_EMPTY)); } } return(result); }
/// <summary> /// Creates Salesforce object. /// </summary> /// <param name="values">Object values.</param> /// <returns>Operation result.</returns> public bool CreateObject <T>(Dictionary <string, IConvertible> values) where T : SalesforceEntity { bool result = false; if (this.CheckConnected()) { // Check parameters if (values == null) { throw (new ArgumentNullException("values")); } // Values should not be empty if (values.Count > 0) { // Construct Salesforce object if (!values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = this._binding.create ( new sObject[] { Constructor.ConstructSObject(typeof(T).Name, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(ERR_ID_FIELD_IS_AUTOGENERATED)); } } else { throw (new InvalidOperationException(ERR_FIELDS_ARE_EMPTY)); } } return(result); }
/// <summary> /// Creates Salesforce. /// </summary> /// <param name="objectTypeName">Object type name.</param> /// <param name="values">Object values.</param> /// <returns>Operation result.</returns> public bool CreateObject(string objectTypeName, Dictionary <string, IConvertible> values) { bool result = false; if (CheckConnected()) { if (String.IsNullOrEmpty(objectTypeName)) { throw (new ArgumentNullException("objectTypeName")); } if (values == null) { throw (new ArgumentNullException("values")); } if (values.Count > 0) { if (!values.ContainsKey(ID_FIELD_NAME)) { SaveResult[] saveResults = _binding.create ( new sObject[] { Constructor.ConstructSObject(objectTypeName, values) } ); result = ((saveResults.Length > 0) && (saveResults[0].success)); } else { throw (new InvalidOperationException(Errors.ERR_ID_FIELD_IS_AUTOGENERATED)); } } else { throw (new InvalidOperationException(Errors.ERR_FIELDS_ARE_EMPTY)); } } return(result); }