diff --git a/Marechai.ApiClient/Computers/ByLetter/Item/Count/CountRequestBuilder.cs b/Marechai.ApiClient/Computers/ByLetter/Item/Count/CountRequestBuilder.cs new file mode 100644 index 00000000..99f2e185 --- /dev/null +++ b/Marechai.ApiClient/Computers/ByLetter/Item/Count/CountRequestBuilder.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable CS0618 +using Marechai.ApiClient.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.ApiClient.Computers.ByLetter.Item.Count +{ + /// + /// Builds and executes requests for operations under \computers\by-letter\{c}\count + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}/count", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CountRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}/count", rawUrl) + { + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.ApiClient.Computers.ByLetter.Item.Count.CountRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.ApiClient.Computers.ByLetter.Item.Count.CountRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.ApiClient/Computers/ByLetter/Item/WithCItemRequestBuilder.cs b/Marechai.ApiClient/Computers/ByLetter/Item/WithCItemRequestBuilder.cs index 43f14df0..4d1ce149 100644 --- a/Marechai.ApiClient/Computers/ByLetter/Item/WithCItemRequestBuilder.cs +++ b/Marechai.ApiClient/Computers/ByLetter/Item/WithCItemRequestBuilder.cs @@ -1,5 +1,6 @@ // #pragma warning disable CS0618 +using Marechai.ApiClient.Computers.ByLetter.Item.Count; using Marechai.ApiClient.Models; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; @@ -17,12 +18,17 @@ namespace Marechai.ApiClient.Computers.ByLetter.Item [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] public partial class WithCItemRequestBuilder : BaseRequestBuilder { + /// The count property + public global::Marechai.ApiClient.Computers.ByLetter.Item.Count.CountRequestBuilder Count + { + get => new global::Marechai.ApiClient.Computers.ByLetter.Item.Count.CountRequestBuilder(PathParameters, RequestAdapter); + } /// /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. - public WithCItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}", pathParameters) + public WithCItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}{?skip*,take*}", pathParameters) { } /// @@ -30,7 +36,7 @@ namespace Marechai.ApiClient.Computers.ByLetter.Item /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. - public WithCItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}", rawUrl) + public WithCItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-letter/{c}{?skip*,take*}", rawUrl) { } /// A List<global::Marechai.ApiClient.Models.MachineDto> @@ -39,11 +45,11 @@ namespace Marechai.ApiClient.Computers.ByLetter.Item /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); @@ -58,11 +64,11 @@ namespace Marechai.ApiClient.Computers.ByLetter.Item /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -79,12 +85,22 @@ namespace Marechai.ApiClient.Computers.ByLetter.Item { return new global::Marechai.ApiClient.Computers.ByLetter.Item.WithCItemRequestBuilder(rawUrl, RequestAdapter); } + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class WithCItemRequestBuilderGetQueryParameters + #pragma warning restore CS1591 + { + [QueryParameter("skip")] + public int? Skip { get; set; } + [QueryParameter("take")] + public int? Take { get; set; } + } /// /// Configuration for the request such as headers, query parameters, and middleware options. /// [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class WithCItemRequestBuilderGetRequestConfiguration : RequestConfiguration + public partial class WithCItemRequestBuilderGetRequestConfiguration : RequestConfiguration { } } diff --git a/Marechai.ApiClient/Computers/ByYear/Item/Count/CountRequestBuilder.cs b/Marechai.ApiClient/Computers/ByYear/Item/Count/CountRequestBuilder.cs new file mode 100644 index 00000000..03e2e63d --- /dev/null +++ b/Marechai.ApiClient/Computers/ByYear/Item/Count/CountRequestBuilder.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable CS0618 +using Marechai.ApiClient.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.ApiClient.Computers.ByYear.Item.Count +{ + /// + /// Builds and executes requests for operations under \computers\by-year\{year}\count + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}/count", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CountRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}/count", rawUrl) + { + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.ApiClient.Computers.ByYear.Item.Count.CountRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.ApiClient.Computers.ByYear.Item.Count.CountRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.ApiClient/Computers/ByYear/Item/WithYearItemRequestBuilder.cs b/Marechai.ApiClient/Computers/ByYear/Item/WithYearItemRequestBuilder.cs index 61fe110f..664c333b 100644 --- a/Marechai.ApiClient/Computers/ByYear/Item/WithYearItemRequestBuilder.cs +++ b/Marechai.ApiClient/Computers/ByYear/Item/WithYearItemRequestBuilder.cs @@ -1,5 +1,6 @@ // #pragma warning disable CS0618 +using Marechai.ApiClient.Computers.ByYear.Item.Count; using Marechai.ApiClient.Models; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; @@ -17,12 +18,17 @@ namespace Marechai.ApiClient.Computers.ByYear.Item [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] public partial class WithYearItemRequestBuilder : BaseRequestBuilder { + /// The count property + public global::Marechai.ApiClient.Computers.ByYear.Item.Count.CountRequestBuilder Count + { + get => new global::Marechai.ApiClient.Computers.ByYear.Item.Count.CountRequestBuilder(PathParameters, RequestAdapter); + } /// /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. - public WithYearItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}", pathParameters) + public WithYearItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}{?skip*,take*}", pathParameters) { } /// @@ -30,7 +36,7 @@ namespace Marechai.ApiClient.Computers.ByYear.Item /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. - public WithYearItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}", rawUrl) + public WithYearItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/by-year/{year}{?skip*,take*}", rawUrl) { } /// A List<global::Marechai.ApiClient.Models.MachineDto> @@ -39,11 +45,11 @@ namespace Marechai.ApiClient.Computers.ByYear.Item /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); @@ -58,11 +64,11 @@ namespace Marechai.ApiClient.Computers.ByYear.Item /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -79,12 +85,22 @@ namespace Marechai.ApiClient.Computers.ByYear.Item { return new global::Marechai.ApiClient.Computers.ByYear.Item.WithYearItemRequestBuilder(rawUrl, RequestAdapter); } + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class WithYearItemRequestBuilderGetQueryParameters + #pragma warning restore CS1591 + { + [QueryParameter("skip")] + public int? Skip { get; set; } + [QueryParameter("take")] + public int? Take { get; set; } + } /// /// Configuration for the request such as headers, query parameters, and middleware options. /// [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class WithYearItemRequestBuilderGetRequestConfiguration : RequestConfiguration + public partial class WithYearItemRequestBuilderGetRequestConfiguration : RequestConfiguration { } } diff --git a/Marechai.ApiClient/Computers/ComputersRequestBuilder.cs b/Marechai.ApiClient/Computers/ComputersRequestBuilder.cs index 51a9a7ba..b54b1923 100644 --- a/Marechai.ApiClient/Computers/ComputersRequestBuilder.cs +++ b/Marechai.ApiClient/Computers/ComputersRequestBuilder.cs @@ -64,7 +64,7 @@ namespace Marechai.ApiClient.Computers /// /// Path parameters for the request /// The request adapter to use to execute the requests. - public ComputersRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers", pathParameters) + public ComputersRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers{?skip*,take*}", pathParameters) { } /// @@ -72,7 +72,7 @@ namespace Marechai.ApiClient.Computers /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. - public ComputersRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers", rawUrl) + public ComputersRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers{?skip*,take*}", rawUrl) { } /// A List<global::Marechai.ApiClient.Models.MachineDto> @@ -81,11 +81,11 @@ namespace Marechai.ApiClient.Computers /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); @@ -100,11 +100,11 @@ namespace Marechai.ApiClient.Computers /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -121,12 +121,22 @@ namespace Marechai.ApiClient.Computers { return new global::Marechai.ApiClient.Computers.ComputersRequestBuilder(rawUrl, RequestAdapter); } + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ComputersRequestBuilderGetQueryParameters + #pragma warning restore CS1591 + { + [QueryParameter("skip")] + public int? Skip { get; set; } + [QueryParameter("take")] + public int? Take { get; set; } + } /// /// Configuration for the request such as headers, query parameters, and middleware options. /// [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class ComputersRequestBuilderGetRequestConfiguration : RequestConfiguration + public partial class ComputersRequestBuilderGetRequestConfiguration : RequestConfiguration { } } diff --git a/Marechai.ApiClient/Computers/Prototypes/Count/CountRequestBuilder.cs b/Marechai.ApiClient/Computers/Prototypes/Count/CountRequestBuilder.cs new file mode 100644 index 00000000..febde425 --- /dev/null +++ b/Marechai.ApiClient/Computers/Prototypes/Count/CountRequestBuilder.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable CS0618 +using Marechai.ApiClient.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.ApiClient.Computers.Prototypes.Count +{ + /// + /// Builds and executes requests for operations under \computers\prototypes\count + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes/count", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CountRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes/count", rawUrl) + { + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.ApiClient.Computers.Prototypes.Count.CountRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.ApiClient.Computers.Prototypes.Count.CountRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CountRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.ApiClient/Computers/Prototypes/PrototypesRequestBuilder.cs b/Marechai.ApiClient/Computers/Prototypes/PrototypesRequestBuilder.cs index 9e1d4a9b..9c71d101 100644 --- a/Marechai.ApiClient/Computers/Prototypes/PrototypesRequestBuilder.cs +++ b/Marechai.ApiClient/Computers/Prototypes/PrototypesRequestBuilder.cs @@ -1,5 +1,6 @@ // #pragma warning disable CS0618 +using Marechai.ApiClient.Computers.Prototypes.Count; using Marechai.ApiClient.Models; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; @@ -17,12 +18,17 @@ namespace Marechai.ApiClient.Computers.Prototypes [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] public partial class PrototypesRequestBuilder : BaseRequestBuilder { + /// The count property + public global::Marechai.ApiClient.Computers.Prototypes.Count.CountRequestBuilder Count + { + get => new global::Marechai.ApiClient.Computers.Prototypes.Count.CountRequestBuilder(PathParameters, RequestAdapter); + } /// /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. - public PrototypesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes", pathParameters) + public PrototypesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes{?skip*,take*}", pathParameters) { } /// @@ -30,7 +36,7 @@ namespace Marechai.ApiClient.Computers.Prototypes /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. - public PrototypesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes", rawUrl) + public PrototypesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/computers/prototypes{?skip*,take*}", rawUrl) { } /// A List<global::Marechai.ApiClient.Models.MachineDto> @@ -39,11 +45,11 @@ namespace Marechai.ApiClient.Computers.Prototypes /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); @@ -58,11 +64,11 @@ namespace Marechai.ApiClient.Computers.Prototypes /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -79,12 +85,22 @@ namespace Marechai.ApiClient.Computers.Prototypes { return new global::Marechai.ApiClient.Computers.Prototypes.PrototypesRequestBuilder(rawUrl, RequestAdapter); } + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class PrototypesRequestBuilderGetQueryParameters + #pragma warning restore CS1591 + { + [QueryParameter("skip")] + public int? Skip { get; set; } + [QueryParameter("take")] + public int? Take { get; set; } + } /// /// Configuration for the request such as headers, query parameters, and middleware options. /// [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class PrototypesRequestBuilderGetRequestConfiguration : RequestConfiguration + public partial class PrototypesRequestBuilderGetRequestConfiguration : RequestConfiguration { } } diff --git a/Marechai.ApiClient/kiota-lock.json b/Marechai.ApiClient/kiota-lock.json index 545589ed..3db55949 100644 --- a/Marechai.ApiClient/kiota-lock.json +++ b/Marechai.ApiClient/kiota-lock.json @@ -1,5 +1,5 @@ { - "descriptionHash": "610A3BFE8E80FF8A221159EF3848C28F0B4A93F9AC132A014EBD8412519DE129511884F7D649B8706719C61F9581450DBE293CFDB8B1BD0EA0D159B5D021151A", + "descriptionHash": "BCE1BD4B860A87080CB7EB18BDB65E55A84B280A1EF038136D54293A6878B3DA141194298E64B8DE0EF5507D71A58CE366B1C9960E3389A429E06699FA750736", "descriptionLocation": "../../../../../tmp/openapi.json", "lockFileVersion": "1.0.0", "kiotaVersion": "1.31.1", diff --git a/Marechai.Server/Controllers/ComputersController.cs b/Marechai.Server/Controllers/ComputersController.cs index fe1a9ab8..a1000a73 100644 --- a/Marechai.Server/Controllers/ComputersController.cs +++ b/Marechai.Server/Controllers/ComputersController.cs @@ -25,6 +25,7 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Marechai.Data; using Marechai.Data.Dtos; @@ -70,75 +71,135 @@ public class ComputersController(MarechaiContext context) : ControllerBase [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public Task> GetComputersByLetterAsync(char c) => context.Machines.Include(m => m.Company) - .Where(m => - m.Type == MachineType.Computer && - EF.Functions.Like(m.Name, $"{c}%")) - .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) - .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)) - .Select(m => new MachineDto - { - Id = m.Id, - Name = m.Name, - Company = m.Company.Name, - Introduced = m.Introduced - }) - .ToListAsync(); + public Task> GetComputersByLetterAsync(char c, [FromQuery] int? skip = null, + [FromQuery] int? take = null, + CancellationToken cancellationToken = default) + { + IQueryable ordered = context.Machines.Include(m => m.Company) + .Where(m => m.Type == MachineType.Computer && + EF.Functions.Like(m.Name, $"{c}%")) + .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) + .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)); + + if(skip.HasValue) ordered = ordered.Skip(skip.Value); + if(take.HasValue) ordered = ordered.Take(take.Value); + + return ordered.Select(m => new MachineDto + { + Id = m.Id, + Name = m.Name, + Company = m.Company.Name, + Introduced = m.Introduced + }) + .ToListAsync(cancellationToken); + } + + [HttpGet("by-letter/{c}/count")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + public Task GetComputersByLetterCountAsync(char c, CancellationToken cancellationToken = default) => + context.Machines + .Where(m => m.Type == MachineType.Computer && EF.Functions.Like(m.Name, $"{c}%")) + .CountAsync(cancellationToken); [HttpGet("by-year/{year:int}")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public Task> GetComputersByYearAsync(int year) => context.Machines.Include(m => m.Company) - .Where(m => - m.Type == MachineType.Computer && - m.Introduced != null && - m.Introduced.Value.Year == year) - .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) - .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)) - .Select(m => new MachineDto - { - Id = m.Id, - Name = m.Name, - Company = m.Company.Name, - Introduced = m.Introduced - }) - .ToListAsync(); + public Task> GetComputersByYearAsync(int year, [FromQuery] int? skip = null, + [FromQuery] int? take = null, + CancellationToken cancellationToken = default) + { + IQueryable ordered = context.Machines.Include(m => m.Company) + .Where(m => m.Type == MachineType.Computer && + m.Introduced != null && + m.Introduced.Value.Year == year) + .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) + .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)); + + if(skip.HasValue) ordered = ordered.Skip(skip.Value); + if(take.HasValue) ordered = ordered.Take(take.Value); + + return ordered.Select(m => new MachineDto + { + Id = m.Id, + Name = m.Name, + Company = m.Company.Name, + Introduced = m.Introduced + }) + .ToListAsync(cancellationToken); + } + + [HttpGet("by-year/{year:int}/count")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + public Task GetComputersByYearCountAsync(int year, CancellationToken cancellationToken = default) => + context.Machines + .Where(m => m.Type == MachineType.Computer && + m.Introduced != null && + m.Introduced.Value.Year == year) + .CountAsync(cancellationToken); [HttpGet] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public Task> GetComputersAsync() => context.Machines.Include(m => m.Company) - .Where(m => m.Type == MachineType.Computer) - .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) - .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)) - .Select(m => new MachineDto - { - Id = m.Id, - Name = m.Name, - Company = m.Company.Name, - Introduced = m.Introduced - }) - .ToListAsync(); + public Task> GetComputersAsync([FromQuery] int? skip = null, [FromQuery] int? take = null, + CancellationToken cancellationToken = default) + { + IQueryable ordered = context.Machines.Include(m => m.Company) + .Where(m => m.Type == MachineType.Computer) + .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) + .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)); + + if(skip.HasValue) ordered = ordered.Skip(skip.Value); + if(take.HasValue) ordered = ordered.Take(take.Value); + + return ordered.Select(m => new MachineDto + { + Id = m.Id, + Name = m.Name, + Company = m.Company.Name, + Introduced = m.Introduced + }) + .ToListAsync(cancellationToken); + } [HttpGet("prototypes")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public Task> GetPrototypesAsync() => context.Machines.Include(m => m.Company) - .Where(m => m.Type == MachineType.Computer && - m.Prototype) - .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) - .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)) - .Select(m => new MachineDto - { - Id = m.Id, - Name = m.Name, - Company = m.Company.Name, - Prototype = m.Prototype - }) - .ToListAsync(); + public Task> GetPrototypesAsync([FromQuery] int? skip = null, [FromQuery] int? take = null, + CancellationToken cancellationToken = default) + { + IQueryable ordered = context.Machines.Include(m => m.Company) + .Where(m => m.Type == MachineType.Computer && m.Prototype) + .OrderBy(m => MarechaiContext.NaturalSortKey(m.Company.Name)) + .ThenBy(m => MarechaiContext.NaturalSortKey(m.Name)); + + if(skip.HasValue) ordered = ordered.Skip(skip.Value); + if(take.HasValue) ordered = ordered.Take(take.Value); + + return ordered.Select(m => new MachineDto + { + Id = m.Id, + Name = m.Name, + Company = m.Company.Name, + Prototype = m.Prototype + }) + .ToListAsync(cancellationToken); + } + + [HttpGet("prototypes/count")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + public Task GetPrototypesCountAsync(CancellationToken cancellationToken = default) => + context.Machines + .Where(m => m.Type == MachineType.Computer && m.Prototype) + .CountAsync(cancellationToken); [HttpGet("companies")] [AllowAnonymous] diff --git a/Marechai/Pages/Computers/Search.razor b/Marechai/Pages/Computers/Search.razor index 9f6b1a0d..29987fe4 100644 --- a/Marechai/Pages/Computers/Search.razor +++ b/Marechai/Pages/Computers/Search.razor @@ -32,7 +32,7 @@ @inherits OwningComponentBase @inject IStringLocalizer L -@if(_computers is null) +@if(!_initialized) {
@@ -56,17 +56,25 @@ } -@if(_computers?.Count > 0) +@if(_total > 0) { - @string.Format(L["{0} computers found in the database."], _computers.Count) - - @foreach(MachineDto computer in _computers) + @string.Format(L["{0} computers found in the database."], _total) +
+ + + + @computer.Company @computer.Name + + + +
+ @if(_loadingMore) { - - @computer.Company @computer.Name - +
+ +
} - +
} else { @@ -78,4 +86,4 @@ else { @L["There are no computers found introduced this year."] } -} \ No newline at end of file +} diff --git a/Marechai/Pages/Computers/Search.razor.cs b/Marechai/Pages/Computers/Search.razor.cs index f4c45ab2..e467f749 100644 --- a/Marechai/Pages/Computers/Search.razor.cs +++ b/Marechai/Pages/Computers/Search.razor.cs @@ -23,21 +23,33 @@ // Copyright © 2003-2026 Natalia Portillo *******************************************************************************/ +using System; using System.Collections.Generic; using System.Threading.Tasks; using Marechai.ApiClient.Models; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; namespace Marechai.Pages.Computers; -public partial class Search +public partial class Search : IAsyncDisposable { - char? _character; - List _computers; - bool _loaded; - bool _showPrototypes; - string _lastStartingCharacter; - int? _lastYear; + const int _pageSize = 100; + readonly string _sentinelId = $"computers-search-sentinel-{Guid.NewGuid():N}"; + readonly string _scrollerId = $"computers-search-scroll-{Guid.NewGuid():N}"; + readonly List _computers = []; + char? _character; + bool _initialized; + bool _loadingMore; + bool _observerRegistered; + bool _showPrototypes; + string _lastStartingCharacter; + int? _lastYear; + int _total; + DotNetObjectReference _selfRef; + + [Inject] + IJSRuntime JS { get; set; } [Parameter] public int? Year { get; set; } @@ -45,30 +57,29 @@ public partial class Search [Parameter] public string StartingCharacter { get; set; } + bool HasMore => _computers.Count < _total; + protected override void OnParametersSet() { if(Year == _lastYear && StartingCharacter == _lastStartingCharacter) return; _lastYear = Year; _lastStartingCharacter = StartingCharacter; - _loaded = false; + _initialized = false; } protected override async Task OnAfterRenderAsync(bool firstRender) { - if(_loaded) return; - - _character = null; - _showPrototypes = false; - - if(StartingCharacter == "prototypes") + if(!_initialized) { - _showPrototypes = true; - _computers = await Service.GetPrototypesAsync(); - } - else - { - if(!string.IsNullOrWhiteSpace(StartingCharacter) && StartingCharacter.Length == 1) + _character = null; + _showPrototypes = false; + _total = 0; + _computers.Clear(); + + if(StartingCharacter == "prototypes") + _showPrototypes = true; + else if(!string.IsNullOrWhiteSpace(StartingCharacter) && StartingCharacter.Length == 1) { _character = StartingCharacter[0]; @@ -79,14 +90,117 @@ public partial class Search if(_character < '0' || _character > '9' && _character < 'A' || _character > 'Z') _character = null; } - if(_character.HasValue) _computers = await Service.GetComputersByLetterAsync(_character.Value); + // Stop the previous observer (if any) before swapping in a new + // batch — the sentinel/scroller IDs are stable per page instance, + // but a route-parameter change forces a fresh data load and the + // observer must be re-armed once the new sentinel has rendered. + await UnobserveAsync(); - if(Year.HasValue && _computers is null) _computers = await Service.GetComputersByYearAsync(Year.Value); + // Fetch the total count + first page in parallel so the page is + // fully painted in one round-trip pair. + Task countTask = GetCurrentCountAsync(); + Task> firstPageTask = FetchBatchAsync(0, _pageSize); - _computers ??= await Service.GetComputersAsync(); + await Task.WhenAll(countTask, firstPageTask); + + _total = countTask.Result; + _computers.AddRange(firstPageTask.Result); + _initialized = true; + + StateHasChanged(); + return; } - _loaded = true; - StateHasChanged(); + // Register the IntersectionObserver once the sentinel has been + // rendered. The observer keeps the same target reference, so this is + // a one-shot until UnobserveAsync clears the flag. + if(!_observerRegistered && HasMore) + { + _selfRef ??= DotNetObjectReference.Create(this); + + try + { + await JS.InvokeVoidAsync("marechaiInfiniteScroll.observe", _sentinelId, _selfRef, $"#{_scrollerId}", + "200px"); + _observerRegistered = true; + } + catch(JSDisconnectedException) + { + // Circuit gone — nothing to do. + } + } } -} \ No newline at end of file + + /// + /// Invoked by the IntersectionObserver in infinite-scroll.js when the + /// sentinel scrolls into view. Loads the next page, appends it to the + /// in-memory list, and re-renders. + /// + [JSInvokable] + public async Task OnSentinelVisibleAsync() + { + if(_loadingMore || !HasMore) return; + + _loadingMore = true; + StateHasChanged(); + + try + { + List next = await FetchBatchAsync(_computers.Count, _pageSize); + _computers.AddRange(next); + + // If the very last page just arrived, stop the observer so it + // doesn't keep firing as the user scrolls past the new tail. + if(!HasMore) await UnobserveAsync(); + } + finally + { + _loadingMore = false; + StateHasChanged(); + } + } + + Task GetCurrentCountAsync() + { + if(_showPrototypes) return Service.GetPrototypesCountAsync(); + + if(_character.HasValue) return Service.GetComputersByLetterCountAsync(_character.Value); + + if(Year.HasValue) return Service.GetComputersByYearCountAsync(Year.Value); + + return Service.GetComputersCountAsync(); + } + + Task> FetchBatchAsync(int skip, int take) + { + if(_showPrototypes) return Service.GetPrototypesAsync(skip, take); + + if(_character.HasValue) return Service.GetComputersByLetterAsync(_character.Value, skip, take); + + if(Year.HasValue) return Service.GetComputersByYearAsync(Year.Value, skip, take); + + return Service.GetComputersAsync(skip, take); + } + + async Task UnobserveAsync() + { + if(!_observerRegistered) return; + + try + { + await JS.InvokeVoidAsync("marechaiInfiniteScroll.unobserve", _sentinelId); + } + catch(JSDisconnectedException) + { + // Circuit gone; nothing to do. + } + + _observerRegistered = false; + } + + public async ValueTask DisposeAsync() + { + await UnobserveAsync(); + _selfRef?.Dispose(); + } +} diff --git a/Marechai/Services/ComputersService.cs b/Marechai/Services/ComputersService.cs index 1facec0b..93d30887 100644 --- a/Marechai/Services/ComputersService.cs +++ b/Marechai/Services/ComputersService.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Marechai.ApiClient.Models; @@ -74,11 +75,16 @@ public class ComputersService(Marechai.ApiClient.Client client) } } - public async Task> GetComputersByLetterAsync(char c) + public async Task> GetComputersByLetterAsync(char c, int? skip = null, int? take = null, + CancellationToken cancellationToken = default) { try { - List machines = await client.Computers.ByLetter[c.ToString()].GetAsync(); + List machines = await client.Computers.ByLetter[c.ToString()].GetAsync(config => + { + if(skip.HasValue) config.QueryParameters.Skip = skip.Value; + if(take.HasValue) config.QueryParameters.Take = take.Value; + }, cancellationToken); return machines ?? []; } @@ -88,11 +94,31 @@ public class ComputersService(Marechai.ApiClient.Client client) } } - public async Task> GetComputersByYearAsync(int year) + public async Task GetComputersByLetterCountAsync(char c, CancellationToken cancellationToken = default) { try { - List machines = await client.Computers.ByYear[year].GetAsync(); + int? count = await client.Computers.ByLetter[c.ToString()].Count + .GetAsync(cancellationToken: cancellationToken); + + return count ?? 0; + } + catch + { + return 0; + } + } + + public async Task> GetComputersByYearAsync(int year, int? skip = null, int? take = null, + CancellationToken cancellationToken = default) + { + try + { + List machines = await client.Computers.ByYear[year].GetAsync(config => + { + if(skip.HasValue) config.QueryParameters.Skip = skip.Value; + if(take.HasValue) config.QueryParameters.Take = take.Value; + }, cancellationToken); return machines ?? []; } @@ -102,11 +128,30 @@ public class ComputersService(Marechai.ApiClient.Client client) } } - public async Task> GetComputersAsync() + public async Task GetComputersByYearCountAsync(int year, CancellationToken cancellationToken = default) { try { - List machines = await client.Computers.GetAsync(); + int? count = await client.Computers.ByYear[year].Count.GetAsync(cancellationToken: cancellationToken); + + return count ?? 0; + } + catch + { + return 0; + } + } + + public async Task> GetComputersAsync(int? skip = null, int? take = null, + CancellationToken cancellationToken = default) + { + try + { + List machines = await client.Computers.GetAsync(config => + { + if(skip.HasValue) config.QueryParameters.Skip = skip.Value; + if(take.HasValue) config.QueryParameters.Take = take.Value; + }, cancellationToken); return machines ?? []; } @@ -116,11 +161,16 @@ public class ComputersService(Marechai.ApiClient.Client client) } } - public async Task> GetPrototypesAsync() + public async Task> GetPrototypesAsync(int? skip = null, int? take = null, + CancellationToken cancellationToken = default) { try { - List machines = await client.Computers.Prototypes.GetAsync(); + List machines = await client.Computers.Prototypes.GetAsync(config => + { + if(skip.HasValue) config.QueryParameters.Skip = skip.Value; + if(take.HasValue) config.QueryParameters.Take = take.Value; + }, cancellationToken); return machines ?? []; } @@ -130,6 +180,20 @@ public class ComputersService(Marechai.ApiClient.Client client) } } + public async Task GetPrototypesCountAsync(CancellationToken cancellationToken = default) + { + try + { + int? count = await client.Computers.Prototypes.Count.GetAsync(cancellationToken: cancellationToken); + + return count ?? 0; + } + catch + { + return 0; + } + } + public async Task> GetCompaniesAsync() { try