public void Flow_tests() { var putDocResponse = Client.Documents.PostAsync(ClientTestData.Artists.Artist1Json).Result; var putRequest = new PutAttachmentRequest( putDocResponse.Id, putDocResponse.Rev, ClientTestData.Attachments.One.Name, ClientTestData.Attachments.One.ContentType, ClientTestData.Attachments.One.Bytes); var putAttachmentResponse = SUT.PutAsync(putRequest).Result; putAttachmentResponse.Should().BeSuccessfulPut(ClientTestData.Artists.Artist1Id); var getRequest = new GetAttachmentRequest( putAttachmentResponse.Id, putAttachmentResponse.Rev, ClientTestData.Attachments.One.Name); var getResponse = SUT.GetAsync(getRequest).Result; getResponse.Should().BeSuccessfulGet(ClientTestData.Artists.Artist1Id, ClientTestData.Attachments.One.Name); var deleteRequest = new DeleteAttachmentRequest( putAttachmentResponse.Id, putAttachmentResponse.Rev, ClientTestData.Attachments.One.Name); var deleteResponse = SUT.DeleteAsync(deleteRequest).Result; deleteResponse.Should().BeSuccessfulDelete(ClientTestData.Artists.Artist1Id); }
public virtual HttpRequest Create(DeleteAttachmentRequest request) { var httpRequest = CreateFor<DeleteAttachmentRequest>(HttpMethod.Delete, GenerateRequestUrl(request.DocId, request.DocRev, request.Name)); httpRequest.SetIfMatch(request.DocRev); return httpRequest; }
public virtual HttpRequest Create(DeleteAttachmentRequest request) { var httpRequest = CreateFor <DeleteAttachmentRequest>(HttpMethod.Delete, GenerateRequestUrl(request.DocId, request.DocRev, request.Name)); httpRequest.SetIfMatch(request.DocRev); return(httpRequest); }
public virtual async Task <DocumentHeaderResponse> DeleteAsync(DeleteAttachmentRequest request, CancellationToken cancellationToken = default) { var httpRequest = DeleteAttachmentHttpRequestFactory.Create(request); using (var res = await SendAsync(httpRequest, cancellationToken).ForAwait()) { return(await DocumentHeaderResponseFactory.CreateAsync(res).ForAwait()); } }
public virtual async Task <DocumentHeaderResponse> DeleteAsync(DeleteAttachmentRequest request) { var httpRequest = CreateHttpRequest(request); using (var res = await SendAsync(httpRequest).ForAwait()) { return(ProcessDocumentHeaderResponse(res)); } }
public virtual HttpRequest Create(DeleteAttachmentRequest request) { Ensure.That(request, "request").IsNotNull(); var httpRequest = new HttpRequest(HttpMethod.Delete, GenerateRelativeUrl(request)) .SetRequestTypeHeader(request.GetType()) .SetIfMatchHeader(request.DocRev); return(httpRequest); }
protected virtual string GenerateRelativeUrl(DeleteAttachmentRequest request) { var urlParams = new UrlParams(); urlParams.AddRequired("rev", request.DocRev); return(string.Format("/{0}/{1}{2}", new UrlSegment(request.DocId), new UrlSegment(request.Name), new QueryString(urlParams))); }
/// <summary> /// Deletes Attachment /// </summary> /// <param name="id">Attachment Id</param> protected void DeleteAttachment(ISession <PrivateAuthentication> session, string id) { if (null == id) { Log.Info("Empty id attachment, nothing to process"); } else { bool ret = session.Call(DeleteAttachmentRequest.DeleteField(long.Parse(id))); if (!ret) { Log.Warn("Can not delete the attachment!"); } Log.Info("Ending the DeleteAttachment"); } }
public void When_DELETE_of_an_existing_attachment_The_response_is_ok() { var putDocResponse = Client.Documents.PostAsync(ClientTestData.Artists.Artist1Json).Result; var putRequest = new PutAttachmentRequest( putDocResponse.Id, putDocResponse.Rev, ClientTestData.Attachments.One.Name, ClientTestData.Attachments.One.ContentType, ClientTestData.Attachments.One.Bytes); var putAttachmentResponse = SUT.PutAsync(putRequest).Result; var deleteRequest = new DeleteAttachmentRequest( putAttachmentResponse.Id, putAttachmentResponse.Rev, ClientTestData.Attachments.One.Name); var deleteResponse = SUT.DeleteAsync(deleteRequest).Result; deleteResponse.Should().BeSuccessfulDelete(ClientTestData.Artists.Artist1Id); }
// Token: 0x0600012E RID: 302 RVA: 0x0000514C File Offset: 0x0000334C public static bool DeleteAttachment(AttachmentIdType attachmentId) { bool result = false; if (attachmentId != null) { DeleteAttachmentJsonRequest deleteAttachmentJsonRequest = new DeleteAttachmentJsonRequest(); DeleteAttachmentRequest deleteAttachmentRequest = new DeleteAttachmentRequest(); deleteAttachmentRequest.AttachmentIds = new AttachmentIdType[1]; deleteAttachmentRequest.AttachmentIds[0] = attachmentId; deleteAttachmentJsonRequest.Body = deleteAttachmentRequest; OWAService owaservice = new OWAService(); IAsyncResult asyncResult = owaservice.BeginDeleteAttachment(deleteAttachmentJsonRequest, null, null); asyncResult.AsyncWaitHandle.WaitOne(); DeleteAttachmentResponse body = owaservice.EndDeleteAttachment(asyncResult).Body; if (body != null && body.ResponseMessages != null && body.ResponseMessages.Items != null && body.ResponseMessages.Items[0] != null) { result = (body.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError); } } return(result); }
public Response <Attachment> DeleteAttachment(DeleteAttachmentRequest request) { Response <Attachment> response = new Response <Attachment>(); if (request == null) { ArgumentNullException ex = new ArgumentNullException("DeleteAttachment request"); LogError(ex); response.ErrorCode = ErrorCode.Argument; response.Exception = ex; return(response); } try { AttachmentAccessor accessor = new AttachmentAccessor(); response.Result = accessor.DeleteAttachment(request.ID); if (response.Result.ID == 0) { response.IsSuccess = false; response.ErrorCode = ErrorCode.Argument; } else { response.IsSuccess = true; } } catch (Exception ex) { LogError(ex); response.IsSuccess = false; response.ErrorCode = ErrorCode.Technical; } return(response); }
protected virtual HttpRequest CreateHttpRequest(DeleteAttachmentRequest request) { return(DeleteAttachmentHttpRequestFactory.Create(request)); }
public static Task <DocumentHeaderResponse> PerformAsync(this IMyCouchClient client, DeleteAttachmentRequest request) { return(client.Attachments.DeleteAsync(request)); }