/// <summary> /// Send a <see cref="HttpMethod.Delete"/> request as an asynchronous operation. /// </summary> /// <param name="urlSuffix">The url suffix for the operation.</param> /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param> /// <param name="args">The operation arguments to be substituted within the <paramref name="urlSuffix"/>.</param> /// <param name="memberName">The method or property name of the caller to the method.</param> /// <param name="filePath">The full path of the source file that contains the caller.</param> /// <param name="lineNumber">The line number in the source file at which the method is called.</param> /// <returns>The <see cref="WebApiAgentResult{T}"/>.</returns> public async Task <WebApiAgentResult> DeleteAsync(string urlSuffix, WebApiRequestOptions?requestOptions = null, WebApiArg[]?args = null, [CallerMemberName] string?memberName = null, [CallerFilePath] string?filePath = null, [CallerLineNumber] int lineNumber = 0) { var uri = CreateFullUri(urlSuffix, args, requestOptions); return(await WebApiServiceAgentInvoker.Default.InvokeAsync(this, async() => { var result = new WebApiAgentResult(await Client.SendAsync(CreateRequestMessage(HttpMethod.Delete, uri, requestOptions: requestOptions)).ConfigureAwait(false)); result.Content = await result.Response.Content.ReadAsStringAsync().ConfigureAwait(false); return VerifyResult(result); }, null !, memberName, filePath, lineNumber).ConfigureAwait(false)); }
/// <summary> /// Send a <see cref="HttpMethod.Delete"/> request as an asynchronous operation. /// </summary> /// <param name="urlSuffix">The url suffix for the operation.</param> /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param> /// <param name="args">The operation arguments to be substituted within the <paramref name="urlSuffix"/>.</param> /// <returns>The <see cref="WebApiAgentResult{T}"/>.</returns> public async Task <WebApiAgentResult> DeleteAsync(string?urlSuffix, WebApiRequestOptions?requestOptions = null, WebApiArg[]?args = null) { var uri = CreateFullUri(urlSuffix, args, requestOptions); return(await WebApiAgentInvoker.Current.InvokeAsync(this, async() => { var result = new WebApiAgentResult(await Args.HttpClient.SendAsync(await CreateRequestMessageAsync(HttpMethod.Delete, uri, requestOptions: requestOptions).ConfigureAwait(false)).ConfigureAwait(false)); result.Content = await result.Response.Content.ReadAsStringAsync().ConfigureAwait(false); return VerifyResult(result); }, null !).ConfigureAwait(false)); }
/// <summary> /// Send a <see cref="HttpMethod.Get"/> request as an asynchronous operation. /// </summary> /// <param name="urlSuffix">The url suffix for the operation.</param> /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param> /// <param name="args">The operation arguments to be substituted within the <paramref name="urlSuffix"/>.</param> /// <returns>The <see cref="WebApiAgentResult"/>.</returns> public async Task <WebApiAgentResult> GetAsync(string?urlSuffix, WebApiRequestOptions?requestOptions = null, WebApiArg[]?args = null) { var uri = CreateFullUri(urlSuffix, args, requestOptions); return(await WebApiAgentInvoker.Current.InvokeAsync(this, async() => { var value = args?.Where(x => x.ArgType == WebApiArgType.FromBody).SingleOrDefault()?.GetValue(); var result = new WebApiAgentResult(await Args.HttpClient.SendAsync(await CreateRequestMessageAsync(HttpMethod.Get, uri, CreateJsonContentFromValue(value), requestOptions).ConfigureAwait(false)).ConfigureAwait(false)); result.Content = await result.Response.Content.ReadAsStringAsync().ConfigureAwait(false); return VerifyResult(result); }, null !).ConfigureAwait(false)); }
/// <summary> /// Send a <see cref="HttpMethod.Post"/> request as an asynchronous operation. /// </summary> /// <param name="urlSuffix">The url suffix for the operation.</param> /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param> /// <param name="args">The operation arguments to be substituted within the <paramref name="urlSuffix"/>.</param> /// <param name="memberName">The method or property name of the caller to the method.</param> /// <param name="filePath">The full path of the source file that contains the caller.</param> /// <param name="lineNumber">The line number in the source file at which the method is called.</param> /// <returns>The <see cref="WebApiAgentResult"/>.</returns> public async Task <WebApiAgentResult> PostAsync(string urlSuffix, WebApiRequestOptions?requestOptions = null, WebApiArg[]?args = null, [CallerMemberName] string?memberName = null, [CallerFilePath] string?filePath = null, [CallerLineNumber] int lineNumber = 0) { var uri = CreateFullUri(urlSuffix, args, requestOptions); return(await WebApiServiceAgentInvoker.Default.InvokeAsync(this, async() => { var value = args?.Where(x => x.ArgType == WebApiArgType.FromBody).SingleOrDefault()?.GetValue(); var result = new WebApiAgentResult(await Client.SendAsync(CreateRequestMessage(HttpMethod.Post, uri, CreateJsonContentFromValue(value), requestOptions)).ConfigureAwait(false)); result.Content = await result.Response.Content.ReadAsStringAsync().ConfigureAwait(false); return VerifyResult(result); }, null !, memberName, filePath, lineNumber).ConfigureAwait(false)); }
/// <summary> /// Applys the <see cref="WebApiRequestOptions"/> to the<see cref="HttpRequestMessage"/>. /// </summary> private static void ApplyWebApiOptions(HttpRequestMessage request, WebApiRequestOptions?requestOptions = null) { if (requestOptions == null || string.IsNullOrEmpty(requestOptions.ETag)) { return; } var etag = requestOptions.ETag.StartsWith("\"", StringComparison.InvariantCultureIgnoreCase) && requestOptions.ETag.EndsWith("\"", StringComparison.InvariantCultureIgnoreCase) ? requestOptions.ETag : "\"" + requestOptions.ETag + "\""; if (request.Method == HttpMethod.Get) { request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(etag)); } else { request.Headers.IfMatch.Add(new EntityTagHeaderValue(etag)); } }
public Task <WebApiAgentResult <Gender> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null) => GenderServiceAgent.GetAsync(id, requestOptions);
public Task <WebApiAgentResult <Product> > GetAsync(int id, WebApiRequestOptions?requestOptions = null) => ProductServiceAgent.GetAsync(id, requestOptions);
public Task <WebApiAgentResult <TripPerson> > GetAsync(string?id, WebApiRequestOptions?requestOptions = null) { return(GetAsync <TripPerson>("api/v1/tripPeople/{id}", requestOptions: requestOptions, args: new WebApiArg[] { new WebApiArg <string?>("id", id) })); }
public Task <WebApiAgentResult <Balance> > GetBalanceAsync(string?accountId, WebApiRequestOptions?requestOptions = null) => AccountServiceAgent.GetBalanceAsync(accountId, requestOptions);
public Task <WebApiAgentResult> DeleteAsync(Guid id, WebApiRequestOptions?requestOptions = null) => RobotServiceAgent.DeleteAsync(id, requestOptions);
public Task <WebApiAgentResult <Robot> > CreateAsync(Robot value, WebApiRequestOptions?requestOptions = null) => RobotServiceAgent.CreateAsync(Check.NotNull(value, nameof(value)), requestOptions);
public Task <WebApiAgentResult <Person> > MergeAsync(Guid fromId, Guid toId, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.MergeAsync(fromId, toId, requestOptions)); }
public Task <WebApiAgentResult <PersonCollectionResult> > GetAll2Async(WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.GetAll2Async(requestOptions)); }
public Task <WebApiAgentResult <PersonCollectionResult> > GetAllAsync(PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.GetAllAsync(paging, requestOptions)); }
public Task <WebApiAgentResult <Employee> > TerminateAsync(TerminationDetail value, Guid id, WebApiRequestOptions?requestOptions = null) => PostAsync <Employee>("api/employees/{id}/terminate", Beef.Check.NotNull(value, nameof(value)), requestOptions: requestOptions, args: new WebApiArg[] { new WebApiArg <Guid>("id", id) });
public Task <WebApiAgentResult> RaisePowerSourceChangeAsync(Guid id, RefDataNamespace.PowerSource?powerSource, WebApiRequestOptions?requestOptions = null) => RobotServiceAgent.RaisePowerSourceChangeAsync(id, powerSource, requestOptions);
public Task <WebApiAgentResult <Robot> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null) => RobotServiceAgent.GetAsync(id, requestOptions);
public Task <WebApiAgentResult> MarkAsync(WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.MarkAsync(requestOptions)); }
public Task <WebApiAgentResult <Robot> > PatchAsync(WebApiPatchOption patchOption, JToken value, Guid id, WebApiRequestOptions?requestOptions = null) => RobotServiceAgent.PatchAsync(patchOption, value, id, requestOptions);
public Task <WebApiAgentResult <PersonDetail> > PatchDetailAsync(WebApiPatchOption patchOption, JToken value, Guid id, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.PatchDetailAsync(patchOption, value, id, requestOptions)); }
public Task <WebApiAgentResult <AccountCollectionResult> > GetAccountsAsync(AccountArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null) => AccountServiceAgent.GetAccountsAsync(args, paging, requestOptions);
public Task <WebApiAgentResult> AddAsync(Person?person, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.AddAsync(person, requestOptions)); }
public Task <WebApiAgentResult <TripPerson> > UpdateAsync(TripPerson value, string?id, WebApiRequestOptions?requestOptions = null) { if (value == null) { throw new ArgumentNullException(nameof(value)); } return(PutAsync <TripPerson>("api/v1/tripPeople/{id}", value, requestOptions: requestOptions, args: new WebApiArg[] { new WebApiArg <string?>("id", id) })); }
public Task <WebApiAgentResult <PersonCollectionResult> > GetByArgsWithEfAsync(PersonArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.GetByArgsWithEfAsync(args, paging, requestOptions)); }
public Task <WebApiAgentResult <TransactionCollectionResult> > GetTransactionsAsync(string?accountId, TransactionArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null) { return(base.GetCollectionResultAsync <TransactionCollectionResult, TransactionCollection, Transaction>("api/v1/banking/accounts/{accountId}/transactions", requestOptions: requestOptions, args: new WebApiArg[] { new WebApiArg <string?>("accountId", accountId), new WebApiArg <TransactionArgs?>("args", args, WebApiArgType.FromUriUseProperties), new WebApiPagingArgsArg("paging", paging) })); }
public Task <WebApiAgentResult <Person> > UpdateWithEfAsync(Person value, Guid id, WebApiRequestOptions?requestOptions = null) { if (value == null) { throw new ArgumentNullException("value"); } return(PersonServiceAgent.UpdateWithEfAsync(value, id, requestOptions)); }
public Task <WebApiAgentResult <ProductCollectionResult> > GetByArgsAsync(ProductArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null) => ProductServiceAgent.GetByArgsAsync(args, paging, requestOptions);
public Task <WebApiAgentResult> DeleteWithEfAsync(Guid id, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.DeleteWithEfAsync(id, requestOptions)); }
public Task <WebApiAgentResult <Gender> > UpdateAsync(Gender value, Guid id, WebApiRequestOptions?requestOptions = null) => GenderServiceAgent.UpdateAsync(Check.NotNull(value, nameof(value)), id, requestOptions);
public Task <WebApiAgentResult <Person> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null) { return(PersonServiceAgent.GetAsync(id, requestOptions)); }