From 919699ddd5e9456f70389830f90a39b51777f63d Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Sun, 24 Nov 2024 15:52:50 +0800 Subject: [PATCH] update apiclient for tenant --- src/CleanAspire.Api/CleanAspire.Api.json | 18 +- .../Endpoints/TenantEndpointRegistrar.cs | 8 +- .../Tenants/Queries/GetAllTenantsQuery.cs | 2 +- src/CleanAspire.ClientApp/Client/ApiClient.cs | 6 + .../Client/Models/CreateTenantCommand.cs | 75 +++++ .../Client/Models/TenantDto.cs | 85 ++++++ .../Client/Models/UpdateTenantCommand.cs | 85 ++++++ .../Tenants/Item/TenantsItemRequestBuilder.cs | 92 ++++++ .../Client/Tenants/TenantsRequestBuilder.cs | 265 ++++++++++++++++++ .../Autocompletes/MultiTenantAutocomplete.cs | 45 +++ .../Pages/Account/SignUp.razor | 26 +- 11 files changed, 681 insertions(+), 26 deletions(-) create mode 100644 src/CleanAspire.ClientApp/Client/Models/CreateTenantCommand.cs create mode 100644 src/CleanAspire.ClientApp/Client/Models/TenantDto.cs create mode 100644 src/CleanAspire.ClientApp/Client/Models/UpdateTenantCommand.cs create mode 100644 src/CleanAspire.ClientApp/Client/Tenants/Item/TenantsItemRequestBuilder.cs create mode 100644 src/CleanAspire.ClientApp/Client/Tenants/TenantsRequestBuilder.cs create mode 100644 src/CleanAspire.ClientApp/Components/Autocompletes/MultiTenantAutocomplete.cs diff --git a/src/CleanAspire.Api/CleanAspire.Api.json b/src/CleanAspire.Api/CleanAspire.Api.json index 311b674..bf46d3d 100644 --- a/src/CleanAspire.Api/CleanAspire.Api.json +++ b/src/CleanAspire.Api/CleanAspire.Api.json @@ -26,12 +26,7 @@ } } } - }, - "security": [ - { - "Identity.Application": [ ] - } - ] + } }, "post": { "tags": [ @@ -153,12 +148,7 @@ } } } - }, - "security": [ - { - "Identity.Application": [ ] - } - ] + } } }, "/weatherforecast": { @@ -1004,7 +994,7 @@ } }, "example": { - "email": "Jalen_Tillman9@hotmail.com", + "email": "Elta98@hotmail.com", "password": "P@ssw0rd!" } }, @@ -1091,7 +1081,7 @@ } }, "example": { - "Email": "Lilla.Jakubowski16@yahoo.com", + "Email": "Eda_Kuphal@gmail.com", "Password": "P@ssw0rd!", "Nickname": "exampleNickname", "Provider": "Local", diff --git a/src/CleanAspire.Api/Endpoints/TenantEndpointRegistrar.cs b/src/CleanAspire.Api/Endpoints/TenantEndpointRegistrar.cs index 8bbb0e2..425f01d 100644 --- a/src/CleanAspire.Api/Endpoints/TenantEndpointRegistrar.cs +++ b/src/CleanAspire.Api/Endpoints/TenantEndpointRegistrar.cs @@ -14,15 +14,17 @@ public class TenantEndpointRegistrar : IEndpointRegistrar { public void RegisterRoutes(IEndpointRouteBuilder routes) { - var group = routes.MapGroup("/tenants").WithTags("tenants").RequireAuthorization(); + var group = routes.MapGroup("/tenants").WithTags("tenants"); group.MapGet("/", async (IMediator mediator) => await mediator.Send(new GetAllTenantsQuery())) .Produces>() + .AllowAnonymous() .WithSummary("Get all tenants") .WithDescription("Returns a list of all tenants in the system."); group.MapGet("/{id}", async (IMediator mediator, [FromRoute] string id) => await mediator.Send(new GetTenantByIdQuery(id))) .Produces() + .AllowAnonymous() .WithSummary("Get tenant by ID") .WithDescription("Returns the details of a specific tenant by their unique ID."); @@ -30,15 +32,17 @@ public void RegisterRoutes(IEndpointRouteBuilder routes) { var id = await mediator.Send(command); return TypedResults.Ok(id); - }) + }).RequireAuthorization() .WithSummary("Create a new tenant") .WithDescription("Creates a new tenant with the provided details."); group.MapPut("/", async (IMediator mediator, [FromBody] UpdateTenantCommand command) => await mediator.Send(command)) + .RequireAuthorization() .WithSummary("Update an existing tenant") .WithDescription("Updates the details of an existing tenant."); group.MapDelete("/", async (IMediator mediator, [FromQuery]string[] ids) => await mediator.Send(new DeleteTenantCommand(ids))) + .RequireAuthorization() .WithSummary("Delete tenants by IDs") .WithDescription("Deletes one or more tenants by their unique IDs."); } diff --git a/src/CleanAspire.Application/Features/Tenants/Queries/GetAllTenantsQuery.cs b/src/CleanAspire.Application/Features/Tenants/Queries/GetAllTenantsQuery.cs index 9037b2c..2634c96 100644 --- a/src/CleanAspire.Application/Features/Tenants/Queries/GetAllTenantsQuery.cs +++ b/src/CleanAspire.Application/Features/Tenants/Queries/GetAllTenantsQuery.cs @@ -26,7 +26,7 @@ public GetAllTenantsQueryHandler(IApplicationDbContext dbContext) public async Task> Handle(GetAllTenantsQuery request, CancellationToken cancellationToken) { - var tenants = await _dbContext.Tenants + var tenants = await _dbContext.Tenants.OrderBy(x=>x.Name) .Select(t => new TenantDto { Id = t.Id, diff --git a/src/CleanAspire.ClientApp/Client/ApiClient.cs b/src/CleanAspire.ClientApp/Client/ApiClient.cs index 71ccb13..e26230f 100644 --- a/src/CleanAspire.ClientApp/Client/ApiClient.cs +++ b/src/CleanAspire.ClientApp/Client/ApiClient.cs @@ -10,6 +10,7 @@ using CleanAspire.Api.Client.Register; using CleanAspire.Api.Client.ResendConfirmationEmail; using CleanAspire.Api.Client.ResetPassword; +using CleanAspire.Api.Client.Tenants; using CleanAspire.Api.Client.Weatherforecast; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions; @@ -75,6 +76,11 @@ public partial class ApiClient : BaseRequestBuilder { get => new global::CleanAspire.Api.Client.ResetPassword.ResetPasswordRequestBuilder(PathParameters, RequestAdapter); } + /// The tenants property + public global::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder Tenants + { + get => new global::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder(PathParameters, RequestAdapter); + } /// The weatherforecast property public global::CleanAspire.Api.Client.Weatherforecast.WeatherforecastRequestBuilder Weatherforecast { diff --git a/src/CleanAspire.ClientApp/Client/Models/CreateTenantCommand.cs b/src/CleanAspire.ClientApp/Client/Models/CreateTenantCommand.cs new file mode 100644 index 0000000..dc1409b --- /dev/null +++ b/src/CleanAspire.ClientApp/Client/Models/CreateTenantCommand.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace CleanAspire.Api.Client.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateTenantCommand : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { get; set; } +#nullable restore +#else + public string Description { get; set; } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { get; set; } +#nullable restore +#else + public string Name { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public CreateTenantCommand() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::CleanAspire.Api.Client.Models.CreateTenantCommand CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::CleanAspire.Api.Client.Models.CreateTenantCommand(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "description", n => { Description = n.GetStringValue(); } }, + { "name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("description", Description); + writer.WriteStringValue("name", Name); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/src/CleanAspire.ClientApp/Client/Models/TenantDto.cs b/src/CleanAspire.ClientApp/Client/Models/TenantDto.cs new file mode 100644 index 0000000..409adce --- /dev/null +++ b/src/CleanAspire.ClientApp/Client/Models/TenantDto.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace CleanAspire.Api.Client.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class TenantDto : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { get; set; } +#nullable restore +#else + public string Description { get; set; } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { get; set; } +#nullable restore +#else + public string Id { get; set; } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { get; set; } +#nullable restore +#else + public string Name { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public TenantDto() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::CleanAspire.Api.Client.Models.TenantDto CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::CleanAspire.Api.Client.Models.TenantDto(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "description", n => { Description = n.GetStringValue(); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("description", Description); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("name", Name); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/src/CleanAspire.ClientApp/Client/Models/UpdateTenantCommand.cs b/src/CleanAspire.ClientApp/Client/Models/UpdateTenantCommand.cs new file mode 100644 index 0000000..aed28ad --- /dev/null +++ b/src/CleanAspire.ClientApp/Client/Models/UpdateTenantCommand.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace CleanAspire.Api.Client.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateTenantCommand : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { get; set; } +#nullable restore +#else + public string Description { get; set; } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { get; set; } +#nullable restore +#else + public string Id { get; set; } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { get; set; } +#nullable restore +#else + public string Name { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public UpdateTenantCommand() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::CleanAspire.Api.Client.Models.UpdateTenantCommand CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::CleanAspire.Api.Client.Models.UpdateTenantCommand(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "description", n => { Description = n.GetStringValue(); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("description", Description); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("name", Name); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/src/CleanAspire.ClientApp/Client/Tenants/Item/TenantsItemRequestBuilder.cs b/src/CleanAspire.ClientApp/Client/Tenants/Item/TenantsItemRequestBuilder.cs new file mode 100644 index 0000000..ff932fd --- /dev/null +++ b/src/CleanAspire.ClientApp/Client/Tenants/Item/TenantsItemRequestBuilder.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 +using CleanAspire.Api.Client.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 CleanAspire.Api.Client.Tenants.Item +{ + /// + /// Builds and executes requests for operations under \tenants\{id} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class TenantsItemRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TenantsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/tenants/{id}", 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 TenantsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/tenants/{id}", rawUrl) + { + } + /// + /// Returns the details of a specific tenant by their unique ID. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#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); + return await RequestAdapter.SendAsync(requestInfo, global::CleanAspire.Api.Client.Models.TenantDto.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Returns the details of a specific tenant by their unique ID. + /// + /// 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", "application/json"); + 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::CleanAspire.Api.Client.Tenants.Item.TenantsItemRequestBuilder WithUrl(string rawUrl) + { + return new global::CleanAspire.Api.Client.Tenants.Item.TenantsItemRequestBuilder(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 TenantsItemRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/src/CleanAspire.ClientApp/Client/Tenants/TenantsRequestBuilder.cs b/src/CleanAspire.ClientApp/Client/Tenants/TenantsRequestBuilder.cs new file mode 100644 index 0000000..f4bba16 --- /dev/null +++ b/src/CleanAspire.ClientApp/Client/Tenants/TenantsRequestBuilder.cs @@ -0,0 +1,265 @@ +// +#pragma warning disable CS0618 +using CleanAspire.Api.Client.Models; +using CleanAspire.Api.Client.Tenants.Item; +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 CleanAspire.Api.Client.Tenants +{ + /// + /// Builds and executes requests for operations under \tenants + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class TenantsRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the CleanAspire.Api.Client.tenants.item collection + /// Unique identifier of the item + /// A + public global::CleanAspire.Api.Client.Tenants.Item.TenantsItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new global::CleanAspire.Api.Client.Tenants.Item.TenantsItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TenantsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/tenants?ids={ids}", 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 TenantsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/tenants?ids={ids}", rawUrl) + { + } + /// + /// Deletes one or more tenants by their unique IDs. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Returns a list of all tenants in the system. + /// + /// A List<global::CleanAspire.Api.Client.Models.TenantDto> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#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 collectionResult = await RequestAdapter.SendCollectionAsync(requestInfo, global::CleanAspire.Api.Client.Models.TenantDto.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// + /// Creates a new tenant with the provided details. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(global::CleanAspire.Api.Client.Models.CreateTenantCommand body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PostAsync(global::CleanAspire.Api.Client.Models.CreateTenantCommand body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates the details of an existing tenant. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PutAsync(global::CleanAspire.Api.Client.Models.UpdateTenantCommand body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PutAsync(global::CleanAspire.Api.Client.Models.UpdateTenantCommand body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPutRequestInformation(body, requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes one or more tenants by their unique IDs. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a list of all tenants in the system. + /// + /// 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, "{+baseurl}/tenants", PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + return requestInfo; + } + /// + /// Creates a new tenant with the provided details. + /// + /// A + /// The request body + /// 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 ToPostRequestInformation(global::CleanAspire.Api.Client.Models.CreateTenantCommand body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(global::CleanAspire.Api.Client.Models.CreateTenantCommand body, Action> requestConfiguration = default) + { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, "{+baseurl}/tenants", PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Updates the details of an existing tenant. + /// + /// A + /// The request body + /// 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 ToPutRequestInformation(global::CleanAspire.Api.Client.Models.UpdateTenantCommand body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPutRequestInformation(global::CleanAspire.Api.Client.Models.UpdateTenantCommand body, Action> requestConfiguration = default) + { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PUT, "{+baseurl}/tenants", PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + 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::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder WithUrl(string rawUrl) + { + return new global::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Deletes one or more tenants by their unique IDs. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class TenantsRequestBuilderDeleteQueryParameters + { +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("ids")] + public string[]? Ids { get; set; } +#nullable restore +#else + [QueryParameter("ids")] + public string[] Ids { get; set; } +#endif + } + /// + /// 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 TenantsRequestBuilderDeleteRequestConfiguration : RequestConfiguration + { + } + /// + /// 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 TenantsRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + /// + /// 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 TenantsRequestBuilderPostRequestConfiguration : RequestConfiguration + { + } + /// + /// 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 TenantsRequestBuilderPutRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/src/CleanAspire.ClientApp/Components/Autocompletes/MultiTenantAutocomplete.cs b/src/CleanAspire.ClientApp/Components/Autocompletes/MultiTenantAutocomplete.cs new file mode 100644 index 0000000..59b553e --- /dev/null +++ b/src/CleanAspire.ClientApp/Components/Autocompletes/MultiTenantAutocomplete.cs @@ -0,0 +1,45 @@ + + +using CleanAspire.Api.Client; +using CleanAspire.Api.Client.Models; +using Microsoft.AspNetCore.Components; +using MudBlazor; + +namespace CleanAspire.ClientApp.Components.Autocompletes; + +public class MultiTenantAutocomplete : MudAutocomplete +{ + public MultiTenantAutocomplete() + { + SearchFunc = SearchKeyValues; + ToStringFunc = dto => dto?.Name; + Dense = true; + ResetValueOnEmptyText = true; + ShowProgressIndicator = true; + } + public List? Tenants { get; set; } = new(); + [Inject] private ApiClient ApiClient { get; set; } = default!; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + Tenants = await ApiClient.Tenants.GetAsync(); + StateHasChanged(); // Trigger a re-render after the tenants are loaded + } + } + private async Task> SearchKeyValues(string? value, CancellationToken cancellation) + { + IEnumerable result; + + if (string.IsNullOrWhiteSpace(value)) + result = Tenants ?? new List(); + else + result = Tenants? + .Where(x => x.Name?.Contains(value, StringComparison.InvariantCultureIgnoreCase) == true || + x.Description?.Contains(value, StringComparison.InvariantCultureIgnoreCase) == true) + .ToList() ?? new List(); + + return await Task.FromResult(result); + } +} diff --git a/src/CleanAspire.ClientApp/Pages/Account/SignUp.razor b/src/CleanAspire.ClientApp/Pages/Account/SignUp.razor index f93e696..a0e57a3 100644 --- a/src/CleanAspire.ClientApp/Pages/Account/SignUp.razor +++ b/src/CleanAspire.ClientApp/Pages/Account/SignUp.razor @@ -16,12 +16,20 @@
- + + + + - + - - + +
@L["I agree to the terms and privacy"]
@@ -34,13 +42,13 @@ @code { private bool waiting = false; private SignupModel model = new(); - + private TenantDto tenantDto = new(); private async Task OnValidSubmit(EditContext context) { try { waiting = true; - var result = await ApiClient.Account.Signup.PostAsync(new SignupRequest() { Email = model.Email, Password = model.Password, LanguageCode = model.LanguageCode, Nickname = model.Nickname, Provider = model.Provider, TimeZoneId = model.TimeZoneId, TenantId = model.TenantId }); + var result = await ApiClient.Account.Signup.PostAsync(new SignupRequest() { Email = model.Email, Password = model.Password, LanguageCode = model.LanguageCode, Nickname = model.Nickname, Provider = model.Provider, TimeZoneId = model.TimeZoneId, TenantId = model.Tenant?.Id }); Navigation.NavigateTo("/account/signupsuccessful"); } catch (Exception e) @@ -77,9 +85,9 @@ [RegularExpression("^[a-z]{2,3}(-[A-Z]{2})?$", ErrorMessage = "Invalid language code format.")] public string? LanguageCode { get; set; } [MaxLength(50, ErrorMessage = "Nickname cannot exceed 50 characters.")] - public string? SuperiorId { get; init; } = Guid.CreateVersion7().ToString(); - [MaxLength(50, ErrorMessage = "Tenant id cannot exceed 50 characters.")] - public string? TenantId { get; init; } = Guid.CreateVersion7().ToString(); + public string? SuperiorId { get; init; } + [Required] + public TenantDto? Tenant { get; set; } [MaxLength(20, ErrorMessage = "Provider cannot exceed 20 characters.")] public string? Provider { get; set; } = "Local";