initial commit

This commit is contained in:
2026-07-21 14:22:06 +07:00
commit 2d7959f202
572 changed files with 45295 additions and 0 deletions
@@ -0,0 +1,55 @@
using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Organization.Branch.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;
namespace Indotalent.Features.Organization.Branch;
public static class BranchEndpoint
{
public static void MapBranchEndpoints(this IEndpointRouteBuilder app)
{
var group = app.MapGroup("/branch").WithTags("Branches")
.RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
.RequireAuthenticatedUser());
group.MapGet("/", async (IMediator mediator) =>
{
var result = await mediator.Send(new GetBranchListQuery());
return result.ToApiResponse("Data branch retrieved successfully");
})
.WithName("GetBranchList");
group.MapGet("/{id}", async (string id, IMediator mediator) =>
{
var result = await mediator.Send(new GetBranchByIdQuery(id));
return result.ToApiResponse(result is not null
? "Branch detail retrieved successfully"
: $"Branch with ID {id} not found");
})
.WithName("GetBranchById");
group.MapPost("/", async (CreateBranchRequest request, IMediator mediator) =>
{
var result = await mediator.Send(new CreateBranchCommand(request));
return result.ToApiResponse("Branch has been created successfully", StatusCodes.Status201Created);
})
.WithName("CreateBranch");
group.MapPost("/update", async (UpdateBranchRequest request, IMediator mediator) =>
{
var result = await mediator.Send(new UpdateBranchCommand(request));
if (!result.Success) return ((object?)null).ToApiResponse("Update failed.");
return result.ToApiResponse("Branch has been updated successfully");
})
.WithName("UpdateBranch");
group.MapPost("/delete/{id}", async (string id, IMediator mediator) =>
{
var result = await mediator.Send(new DeleteBranchByIdCommand(new DeleteBranchByIdRequest(id)));
if (!result) return ((object?)null).ToApiResponse("Delete failed.");
return true.ToApiResponse("Branch has been deleted successfully");
})
.WithName("DeleteBranchById");
}
}