public virtual async Task<HttpContent> Update(Uri requestUri, HttpContent content, IHttp http) { http.OriginalRequest.RequestUri = requestUri; http.OriginalRequest.Content = content; HttpResponseMessage response = await http.SendOriginalAsync(); return response.Content; }
public async Task<JObject> DownloadChanges(Uri requestUri, IHttp http) { //get latest known timestamp for a reqeust string timestamp = await GetLastTimestampForRequest(requestUri); Uri stampedRequestUri; if (timestamp != null) { stampedRequestUri = new Uri(string.Format("{0}&version={1}", requestUri.OriginalString, Uri.EscapeDataString(timestamp))); } else { stampedRequestUri = requestUri; } //send the timestamped request http.OriginalRequest.RequestUri = stampedRequestUri; HttpResponseMessage response = await http.SendOriginalAsync(); JObject json = await ResponseHelper.GetResponseAsJObject(response.Content); // get the tablename out of the uri string tableName = UriHelper.GetTableNameFromUri(requestUri); using (await this.storage.Open()) { JToken newtimestamp; if (json.TryGetValue("__version", out newtimestamp)) { await this.SetLastTimestampForRequest(requestUri, newtimestamp.ToString()); } await this.storage.StoreData(tableName, ResponseHelper.GetResultsJArrayFromJson(json)); await this.storage.RemoveStoredData(tableName, ResponseHelper.GetDeletedJArrayFromJson(json)); } return json; }