/// <summary> /// Delete multiple rows using the provided list of id's and resource identifier. /// </summary> /// <param name="rowIds">A List of identifiers of the rows to be deleted.</param> /// <param name="resourceId">The identifier (4x4) for a resource on the Socrata host to target.</param> /// <returns>A <see cref="SodaResult"/> indicating success or failure.</returns> /// <exception cref="System.ArgumentOutOfRangeException">Thrown if the specified <paramref name="resourceId"/> does not match the Socrata 4x4 pattern.</exception> /// <exception cref="System.InvalidOperationException">Thrown if this SodaClient was initialized without authentication credentials.</exception> public SodaResult DeleteRow(List <string> rowIds, string resourceId) { if (rowIds.Count == 0) { return new SodaResult() { Message = "No row identifiers provided to delete" } } ; if (FourByFour.IsNotValid(resourceId)) { throw new ArgumentOutOfRangeException("resourceId", "The provided resourceId is not a valid Socrata (4x4) resource identifier."); } if (String.IsNullOrEmpty(Username) || String.IsNullOrEmpty(password)) { throw new InvalidOperationException("Write operations require an authenticated client."); } //Get the unique identifier field var metaData = GetMetadata(resourceId); var idFieldName = metaData.RowIdentifierField; //construct the json payload string jsonPayload = PayloadBuilder.GetDeletePayload(idFieldName, rowIds); return(Upsert(jsonPayload, SodaDataFormat.JSON, resourceId)); }
/// <summary> /// Delete a single row using the specified row identifier and the specified resource identifier. /// </summary> /// <param name="rowId">The identifier of the row to be deleted.</param> /// <param name="resourceId">The identifier (4x4) for a resource on the Socrata host to target.</param> /// <returns>A <see cref="SodaResult"/> indicating success or failure.</returns> /// <exception cref="System.ArgumentException">Thrown if the specified <paramref name="rowId"/> is null or empty.</exception> /// <exception cref="System.ArgumentOutOfRangeException">Thrown if the specified <paramref name="resourceId"/> does not match the Socrata 4x4 pattern.</exception> /// <exception cref="System.InvalidOperationException">Thrown if this SodaClient was initialized without authentication credentials.</exception> public SodaResult DeleteRow(string rowId, string resourceId) { if (String.IsNullOrEmpty(rowId)) { throw new ArgumentException("Must specify the row to be deleted using its row identifier.", "rowId"); } if (FourByFour.IsNotValid(resourceId)) { throw new ArgumentOutOfRangeException("resourceId", "The provided resourceId is not a valid Socrata (4x4) resource identifier."); } if (String.IsNullOrEmpty(Username) || String.IsNullOrEmpty(password)) { throw new InvalidOperationException("Write operations require an authenticated client."); } //Get the unique identifier field var metaData = GetMetadata(resourceId); var idFieldName = metaData.RowIdentifierField; //construct the json payload string jsonPayload = PayloadBuilder.GetDeletePayload(idFieldName, rowId); return(Upsert(jsonPayload, SodaDataFormat.JSON, resourceId)); }