Skip to content

Commit

Permalink
update apiclient for tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhu committed Nov 24, 2024
1 parent 26cee1d commit 919699d
Show file tree
Hide file tree
Showing 11 changed files with 681 additions and 26 deletions.
18 changes: 4 additions & 14 deletions src/CleanAspire.Api/CleanAspire.Api.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
}
}
}
},
"security": [
{
"Identity.Application": [ ]
}
]
}
},
"post": {
"tags": [
Expand Down Expand Up @@ -153,12 +148,7 @@
}
}
}
},
"security": [
{
"Identity.Application": [ ]
}
]
}
}
},
"/weatherforecast": {
Expand Down Expand Up @@ -1004,7 +994,7 @@
}
},
"example": {
"email": "Jalen_Tillman9@hotmail.com",
"email": "Elta98@hotmail.com",
"password": "P@ssw0rd!"
}
},
Expand Down Expand Up @@ -1091,7 +1081,7 @@
}
},
"example": {
"Email": "Lilla.Jakubowski16@yahoo.com",
"Email": "Eda_Kuphal@gmail.com",
"Password": "P@ssw0rd!",
"Nickname": "exampleNickname",
"Provider": "Local",
Expand Down
8 changes: 6 additions & 2 deletions src/CleanAspire.Api/Endpoints/TenantEndpointRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,35 @@ 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<IEnumerable<TenantDto>>()
.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<TenantDto>()
.AllowAnonymous()
.WithSummary("Get tenant by ID")
.WithDescription("Returns the details of a specific tenant by their unique ID.");

group.MapPost("/", async (IMediator mediator, [FromBody] CreateTenantCommand command) =>
{
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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GetAllTenantsQueryHandler(IApplicationDbContext dbContext)

public async Task<List<TenantDto>> 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,
Expand Down
6 changes: 6 additions & 0 deletions src/CleanAspire.ClientApp/Client/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,6 +76,11 @@ public partial class ApiClient : BaseRequestBuilder
{
get => new global::CleanAspire.Api.Client.ResetPassword.ResetPasswordRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>The tenants property</summary>
public global::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder Tenants
{
get => new global::CleanAspire.Api.Client.Tenants.TenantsRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>The weatherforecast property</summary>
public global::CleanAspire.Api.Client.Weatherforecast.WeatherforecastRequestBuilder Weatherforecast
{
Expand Down
75 changes: 75 additions & 0 deletions src/CleanAspire.ClientApp/Client/Models/CreateTenantCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// <auto-generated/>
#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
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>The description property</summary>
#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
/// <summary>The name property</summary>
#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
/// <summary>
/// Instantiates a new <see cref="global::CleanAspire.Api.Client.Models.CreateTenantCommand"/> and sets the default values.
/// </summary>
public CreateTenantCommand()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::CleanAspire.Api.Client.Models.CreateTenantCommand"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
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();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "description", n => { Description = n.GetStringValue(); } },
{ "name", n => { Name = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
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
85 changes: 85 additions & 0 deletions src/CleanAspire.ClientApp/Client/Models/TenantDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// <auto-generated/>
#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
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>The description property</summary>
#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
/// <summary>The id property</summary>
#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
/// <summary>The name property</summary>
#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
/// <summary>
/// Instantiates a new <see cref="global::CleanAspire.Api.Client.Models.TenantDto"/> and sets the default values.
/// </summary>
public TenantDto()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::CleanAspire.Api.Client.Models.TenantDto"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
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();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "description", n => { Description = n.GetStringValue(); } },
{ "id", n => { Id = n.GetStringValue(); } },
{ "name", n => { Name = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
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
85 changes: 85 additions & 0 deletions src/CleanAspire.ClientApp/Client/Models/UpdateTenantCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// <auto-generated/>
#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
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>The description property</summary>
#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
/// <summary>The id property</summary>
#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
/// <summary>The name property</summary>
#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
/// <summary>
/// Instantiates a new <see cref="global::CleanAspire.Api.Client.Models.UpdateTenantCommand"/> and sets the default values.
/// </summary>
public UpdateTenantCommand()
{
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::CleanAspire.Api.Client.Models.UpdateTenantCommand"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
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();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "description", n => { Description = n.GetStringValue(); } },
{ "id", n => { Id = n.GetStringValue(); } },
{ "name", n => { Name = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
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
Loading

0 comments on commit 919699d

Please sign in to comment.