using PostFundManagement.Application.Extensions; using PostFundManagement.Application.Services.Grants; using PostFundManagement.Domain.Abstractions; using PostFundManagement.Domain.Extensions; using PostFundManagement.Domain.Models; using PostFundManagement.Domain.Security; namespace PostFundManagement.Api.Endpoints.Grants; [ApiVersionTarget(1)] public class GetAwardByIdEndpoint : IEndpoint { public void Map(IEndpointRouteBuilder builder) { builder.MapGet("api/grants/awards/{awardId}", async (string awardId, GrantsService service, CancellationToken cancellationToken = default) => { var result = await service.GetAwardByIdAsync(awardId, cancellationToken); return result.IsSuccess ? Results.Ok(result.Value) : Results.NotFound(); }) .WithDescription("Get award by ID") .WithName(typeof(GetAwardByIdEndpoint).ToEndpointName()) .MapToApiVersion(new ApiVersion(1)) .Produces(StatusCodes.Status200OK) .Produces(StatusCodes.Status404NotFound) .Produces(StatusCodes.Status401Unauthorized) .WithTags(EndpointTags.Grants); } }