/// <summary> /// Reads resource information from the data source based on the URL and the ETag of the specified entry. /// </summary> /// <param name="request"></param> /// <param name="entry"></param> /// <returns></returns> public virtual AtomEntry ReadEntry(SDataBaseRequest request, AtomEntry entry) { Guard.ArgumentNotNull(request, "request"); try { var requestUrl = request.ToString(); var eTag = entry != null?entry.GetSDataHttpETag() : null; var batchItem = new SDataBatchRequestItem { Url = requestUrl, Method = HttpMethod.Get, ETag = eTag }; if (BatchProcess.Instance.AddToBatch(batchItem)) { return(null); } var operation = new RequestOperation(HttpMethod.Get) { ETag = eTag }; var response = ExecuteRequest(requestUrl, operation, MediaType.AtomEntry, MediaType.Xml); entry = (AtomEntry)response.Content; if (!string.IsNullOrEmpty(response.ETag)) { entry.SetSDataHttpETag(response.ETag); } return(entry); } catch (Exception ex) { throw new SDataClientException(ex.Message, ex); } }
private AtomEntry UpdateEntry(string url, AtomEntry entry) { Guard.ArgumentNotNull(entry, "entry"); try { var eTag = entry.GetSDataHttpETag(); var batchItem = new SDataBatchRequestItem { Url = url, Method = HttpMethod.Put, Entry = entry, ETag = eTag }; if (BatchProcess.Instance.AddToBatch(batchItem)) { return(null); } var operation = new RequestOperation(HttpMethod.Put, entry) { ETag = eTag }; var response = ExecuteRequest(url, operation, MediaType.AtomEntry, MediaType.Xml); entry = (AtomEntry)response.Content; if (!string.IsNullOrEmpty(response.ETag)) { entry.SetSDataHttpETag(response.ETag); } return(entry); } catch (Exception ex) { throw new SDataClientException(ex.Message, ex); } }