Skip to content

Commit

Permalink
Add gender endpoind from Idenitty api.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sharifov committed Feb 7, 2024
1 parent 79ee950 commit 5c81ec7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

internal sealed class MessageBusServiceInstaller : IServiceInstaller
{
public void Install(IServiceCollection services, IConfiguration configuration)
{
public void Install(IServiceCollection services, IConfiguration configuration) =>
services.AddMassTransit(configure =>
{
configure.SetKebabCaseEndpointNameFormatter();
configure.AddConsumers(MessageBus.AssemblyReference.Assembly);
configure.UsingRabbitMq((context, configurator) =>
{
configurator.Host("rabbitmq", "/", hostConfigurator =>
Expand All @@ -19,7 +17,6 @@ public void Install(IServiceCollection services, IConfiguration configuration)
configurator.ConfigureEndpoints(context);
});
configure.AddConsumers(App.AssemblyReference.Assembly);
configure.AddConsumers(MessageBus.AssemblyReference.Assembly);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Install(IServiceCollection services, IConfiguration configuration)
configurator.ConfigureEndpoints(context);
});
configure.AddConsumers(App.AssemblyReference.Assembly);
configure.AddConsumers(MessageBus.AssemblyReference.Assembly);
});

services.AddTransient<IMessageBus, EventBusRabitMQ>();
Expand Down
1 change: 1 addition & 0 deletions crs/Services/Identity/Identity.App/Identity.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<ProjectReference Include="..\Identity.Application\Identity.Application.csproj" />
<ProjectReference Include="..\Identity.Domain\Identity.Domain.csproj" />
<ProjectReference Include="..\Identity.Infrastructure\Identity.Infrastructure.csproj" />
<ProjectReference Include="..\Identity.MessageBus\Identity.MessageBus.csproj" />
<ProjectReference Include="..\Identity.Persistence\Identity.Persistence.csproj" />
<ProjectReference Include="..\Identity.Presentation\Identity.Presentation.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Identity.Application.Users.Queries.GetGenders;

public sealed record GetGendersQuery() : IQuery<GetGendersQueryResponse>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

namespace Identity.Application.Users.Queries.GetGenders;

internal sealed class GetRolesQueryHandler : IQueryHandler<GetGendersQuery, GetGendersQueryResponse>
{
public Task<Result<GetGendersQueryResponse>> Handle(GetGendersQuery request, CancellationToken cancellationToken)
{
var roles = Gender.GetNames();
var response = Result.Success(new GetGendersQueryResponse(roles));
return Task.FromResult(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Identity.Application.Users.Queries.GetGenders;

public sealed record GetGendersQueryResponse(IEnumerable<string> Genders)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Identity.Application.Users.Queries.GetRoles;

public sealed class GetRolesQuery() : IQuery<GetRolesQueryResponse>;
public sealed record GetRolesQuery() : IQuery<GetRolesQueryResponse>;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Identity.Application.Users.Commands.Register;
using Identity.Application.Users.Commands.RetryConfirmEmailSend;
using Identity.Application.Users.Commands.UpdateRefreshToken;
using Identity.Application.Users.Queries.GetGenders;
using Identity.Application.Users.Queries.GetRoles;
using Identity.Presentation.V1.Models;

Expand Down Expand Up @@ -89,4 +90,14 @@ public async Task<IActionResult> GetRoles()
return result.IsSuccess ? Ok(result.Value)
: HandleFailure(result);
}

[HttpGet("genders")]
public async Task<IActionResult> GetGenders()
{
var query = new GetGendersQuery();

var result = await _sender.Send(query);
return result.IsSuccess ? Ok(result.Value)
: HandleFailure(result);
}
}

0 comments on commit 5c81ec7

Please sign in to comment.