示例#1
0
        /// <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));
        }
示例#2
0
        /// <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));
        }
示例#3
0
        /// <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));
        }
示例#4
0
        /// <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));
        }
示例#5
0
        /// <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));
            }
        }
示例#6
0
 public Task <WebApiAgentResult <Gender> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null)
 => GenderServiceAgent.GetAsync(id, requestOptions);
示例#7
0
 public Task <WebApiAgentResult <Product> > GetAsync(int id, WebApiRequestOptions?requestOptions = null)
 => ProductServiceAgent.GetAsync(id, requestOptions);
示例#8
0
 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) }));
 }
示例#9
0
 public Task <WebApiAgentResult <Balance> > GetBalanceAsync(string?accountId, WebApiRequestOptions?requestOptions = null)
 => AccountServiceAgent.GetBalanceAsync(accountId, requestOptions);
示例#10
0
 public Task <WebApiAgentResult> DeleteAsync(Guid id, WebApiRequestOptions?requestOptions = null)
 => RobotServiceAgent.DeleteAsync(id, requestOptions);
示例#11
0
 public Task <WebApiAgentResult <Robot> > CreateAsync(Robot value, WebApiRequestOptions?requestOptions = null)
 => RobotServiceAgent.CreateAsync(Check.NotNull(value, nameof(value)), requestOptions);
示例#12
0
 public Task <WebApiAgentResult <Person> > MergeAsync(Guid fromId, Guid toId, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.MergeAsync(fromId, toId, requestOptions));
 }
示例#13
0
 public Task <WebApiAgentResult <PersonCollectionResult> > GetAll2Async(WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.GetAll2Async(requestOptions));
 }
示例#14
0
 public Task <WebApiAgentResult <PersonCollectionResult> > GetAllAsync(PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.GetAllAsync(paging, requestOptions));
 }
示例#15
0
 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) });
示例#16
0
 public Task <WebApiAgentResult> RaisePowerSourceChangeAsync(Guid id, RefDataNamespace.PowerSource?powerSource, WebApiRequestOptions?requestOptions = null)
 => RobotServiceAgent.RaisePowerSourceChangeAsync(id, powerSource, requestOptions);
示例#17
0
 public Task <WebApiAgentResult <Robot> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null)
 => RobotServiceAgent.GetAsync(id, requestOptions);
示例#18
0
 public Task <WebApiAgentResult> MarkAsync(WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.MarkAsync(requestOptions));
 }
示例#19
0
 public Task <WebApiAgentResult <Robot> > PatchAsync(WebApiPatchOption patchOption, JToken value, Guid id, WebApiRequestOptions?requestOptions = null)
 => RobotServiceAgent.PatchAsync(patchOption, value, id, requestOptions);
示例#20
0
 public Task <WebApiAgentResult <PersonDetail> > PatchDetailAsync(WebApiPatchOption patchOption, JToken value, Guid id, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.PatchDetailAsync(patchOption, value, id, requestOptions));
 }
示例#21
0
 public Task <WebApiAgentResult <AccountCollectionResult> > GetAccountsAsync(AccountArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null)
 => AccountServiceAgent.GetAccountsAsync(args, paging, requestOptions);
示例#22
0
 public Task <WebApiAgentResult> AddAsync(Person?person, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.AddAsync(person, requestOptions));
 }
示例#23
0
        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) }));
        }
示例#24
0
 public Task <WebApiAgentResult <PersonCollectionResult> > GetByArgsWithEfAsync(PersonArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.GetByArgsWithEfAsync(args, paging, requestOptions));
 }
示例#25
0
 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) }));
 }
示例#26
0
        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));
        }
示例#27
0
 public Task <WebApiAgentResult <ProductCollectionResult> > GetByArgsAsync(ProductArgs?args, PagingArgs?paging = null, WebApiRequestOptions?requestOptions = null)
 => ProductServiceAgent.GetByArgsAsync(args, paging, requestOptions);
示例#28
0
 public Task <WebApiAgentResult> DeleteWithEfAsync(Guid id, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.DeleteWithEfAsync(id, requestOptions));
 }
示例#29
0
 public Task <WebApiAgentResult <Gender> > UpdateAsync(Gender value, Guid id, WebApiRequestOptions?requestOptions = null)
 => GenderServiceAgent.UpdateAsync(Check.NotNull(value, nameof(value)), id, requestOptions);
示例#30
0
 public Task <WebApiAgentResult <Person> > GetAsync(Guid id, WebApiRequestOptions?requestOptions = null)
 {
     return(PersonServiceAgent.GetAsync(id, requestOptions));
 }