/// <summary> /// Insert a new object into a table. /// </summary> /// <param name="instance"> /// The instance to insert into the table. /// </param> /// <param name="parameters"> /// A dictionary of user-defined parameters and values to include in the request URI query string. /// </param> /// <returns> /// A task that will complete when the insert finishes. /// </returns> internal Task <IJsonValue> SendInsertAsync(JsonObject instance, IDictionary <string, string> parameters) { if (instance == null) { throw new ArgumentNullException("instance"); } // Make sure the instance doesn't have its ID set for an insertion if (instance.Get(MobileServiceTableUrlBuilder.IdPropertyName) != null) { throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.CannotInsertWithExistingIdMessage, MobileServiceTableUrlBuilder.IdPropertyName), "instance"); } string uriFragment = MobileServiceTableUrlBuilder.GetUriFragment(this.TableName); string queryString = MobileServiceTableUrlBuilder.GetQueryString(parameters); string uriString = MobileServiceTableUrlBuilder.CombinePathAndQuery(uriFragment, queryString); return(this.MobileServiceClient.RequestAsync("POST", uriString, instance) .ContinueWith(t => Patch(instance, t.Result))); }
internal Task <IJsonValue> SendLookupAsync(object id, IDictionary <string, string> parameters) { if (id == null) { throw new ArgumentNullException("id"); } string uriFragment = MobileServiceTableUrlBuilder.GetUriFragment(this.TableName, id); string queryString = MobileServiceTableUrlBuilder.GetQueryString(parameters); string uriString = MobileServiceTableUrlBuilder.CombinePathAndQuery(uriFragment, queryString); return(this.MobileServiceClient.RequestAsync("GET", uriString, null)); }
/// <summary> /// Delete an object from a given table. /// </summary> /// <param name="instance"> /// The instance to delete from the table. /// </param> /// <param name="parameters"> /// A dictionary of user-defined parameters and values to include in the request URI query string. /// </param> /// <returns> /// A task that will complete when the delete finishes. /// </returns> internal Task SendDeleteAsync(JsonObject instance, IDictionary <string, string> parameters) { if (instance == null) { throw new ArgumentNullException("instance"); } string uriFragment = MobileServiceTableUrlBuilder.GetUriFragment(this.TableName, instance); string queryString = MobileServiceTableUrlBuilder.GetQueryString(parameters); string uriString = MobileServiceTableUrlBuilder.CombinePathAndQuery(uriFragment, queryString); return(this.MobileServiceClient.RequestAsync("DELETE", uriString, instance)); }
/// <summary> /// Update an object in a given table. /// </summary> /// <param name="instance"> /// The instance to update in the table. /// </param> /// <param name="parameters"> /// A dictionary of user-defined parameters and values to include in the request URI query string. /// </param> /// <returns> /// A task that will complete when the update finishes. /// </returns> internal Task <IJsonValue> SendUpdateAsync(JsonObject instance, IDictionary <string, string> parameters) { if (instance == null) { throw new ArgumentNullException("instance"); } string uriFragment = MobileServiceTableUrlBuilder.GetUriFragment(this.TableName, instance); string queryString = MobileServiceTableUrlBuilder.GetQueryString(parameters); string uriString = MobileServiceTableUrlBuilder.CombinePathAndQuery(uriFragment, queryString); return(this.MobileServiceClient.RequestAsync("PATCH", uriString, instance) .ContinueWith(t => Patch(instance, t.Result))); }
/// <summary> /// Execute a query against a table. /// </summary> /// <param name="queryString"> /// An object defining the query to execute. /// </param> /// <param name="parameters"> /// A dictionary of user-defined parameters and values to include in the request URI query string. /// </param> /// <returns> /// A task that will return with results when the query finishes. /// </returns> internal Task <IJsonValue> SendReadAsync(string queryString, IDictionary <string, string> parameters) { string uriFragment = MobileServiceTableUrlBuilder.GetUriFragment(this.TableName); string parametersString = MobileServiceTableUrlBuilder.GetQueryString(parameters); // Concatenate the query and the user-defined query string paramters if (!string.IsNullOrEmpty(parametersString)) { if (!string.IsNullOrEmpty(queryString)) { queryString += '&' + parametersString; } else { queryString = parametersString; } } string uriString = MobileServiceTableUrlBuilder.CombinePathAndQuery(uriFragment, queryString); return(this.MobileServiceClient.RequestAsync("GET", uriString, null)); }