Implemented caching on all get endpoints and service layer
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
@@ -14,7 +15,7 @@ public class CreateActivityEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPost("api/projects/activities", async (CreateActivityRequest request,
|
||||
HttpContext context, ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
HttpContext context, IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.CreateActivityAsync(request, context.GetUserId(), cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true } result => Results.Ok(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
@@ -14,7 +15,7 @@ public class CreateProjectEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPost("api/projects", async (CreateProjectRequest request, HttpContext context,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.CreateProjectAsync(request, context.GetUserId(), cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true } result => Results.Ok(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetActivitiesEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/{projectId}/activities", async (string projectId,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.GetActivitiesAsync(projectId, cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true, Value: var activities } => Results.Ok(activities),
|
||||
@@ -28,6 +28,7 @@ public class GetActivitiesEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetActivityEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/activities/{activityId}", async (string activityId,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.GetActivityAsync(activityId, cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true, Value: var activity } => Results.Ok(activity),
|
||||
@@ -30,6 +30,7 @@ public class GetActivityEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetMilestoneEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/milestones/{milestoneId}", async (string milestoneId, ProjectService service,
|
||||
builder.MapGet("api/projects/milestones/{milestoneId}", async (string milestoneId, IProjectService service,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await service.GetMilestoneAsync(milestoneId, cancellationToken) switch
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetMilestonesEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/milestones/{page:int}/{pageSize:int}", async (ProjectService service,
|
||||
builder.MapGet("api/projects/milestones/{page:int}/{pageSize:int}", async (IProjectService service,
|
||||
int page = 1, int pageSize = 100, CancellationToken cancellationToken = default) =>
|
||||
await service.GetMilestonesAsync(Pagination.Create(page, pageSize), cancellationToken) switch
|
||||
{
|
||||
@@ -28,6 +28,7 @@ public class GetMilestonesEndpoint : IEndpoint
|
||||
.Produces<Milestone[]>(StatusCodes.Status200OK)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetProjectEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/{projectId}", async (string projectId, ProjectService service,
|
||||
builder.MapGet("api/projects/{projectId}", async (string projectId, IProjectService service,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await service.GetProjectAsync(projectId, cancellationToken) switch
|
||||
{
|
||||
@@ -31,6 +31,7 @@ public class GetProjectEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetProjectIndicatorsEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/indicators/project/{projectId}", async (string projectId, ProjectService service,
|
||||
builder.MapGet("api/projects/indicators/project/{projectId}", async (string projectId, IProjectService service,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await service.GetProjectIndicatorsAsync(projectIdHash: projectId, cancellationToken) switch
|
||||
{
|
||||
@@ -30,6 +30,7 @@ public class GetProjectIndicatorsEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -15,7 +15,7 @@ public class GetProjectMilestonesEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/{projectId}/milestones", async (string projectId,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.GetProjectMilestonesAsync(projectId, cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true, Value: var milestones } => Results.Ok(milestones),
|
||||
@@ -30,6 +30,7 @@ public class GetProjectMilestonesEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -15,7 +15,7 @@ public class GetProjectRisksEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects/{projectId}/risks", async (string projectId,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.GetProjectRisksAsync(projectId, cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true, Value: var risks } => Results.Ok(risks),
|
||||
@@ -30,6 +30,7 @@ public class GetProjectRisksEndpoint : IEndpoint
|
||||
.Produces(StatusCodes.Status403Forbidden)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -14,7 +14,7 @@ public class GetProjectsEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/projects", async (ProjectService service,
|
||||
builder.MapGet("api/projects", async (IProjectService service,
|
||||
int page = 1, int pageSize = 100, CancellationToken cancellationToken = default) =>
|
||||
await service.GetProjectsAsync(Pagination.Create(page, pageSize), cancellationToken) switch
|
||||
{
|
||||
@@ -27,6 +27,7 @@ public class GetProjectsEndpoint : IEndpoint
|
||||
.Produces<Project[]>(StatusCodes.Status200OK)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithTags(EndpointTags.Projects)
|
||||
.CacheOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
@@ -12,7 +13,7 @@ public sealed class UpdateMilestoneEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPut("api/projects/milestone", async (UpdateMilestoneRequest request, ProjectService service,
|
||||
builder.MapPut("api/projects/milestone", async (UpdateMilestoneRequest request, IProjectService service,
|
||||
HttpContext context, CancellationToken cancellationToken = default) =>
|
||||
await service.UpdateMilestoneAsync(request, context.GetUserId(), cancellationToken) switch
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Errors;
|
||||
@@ -14,20 +15,20 @@ public sealed class UpdateProjectEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPut("api/projects", async (UpdateProjectRequest request,
|
||||
ProjectService service, HttpContext context, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, HttpContext context, CancellationToken cancellationToken = default) =>
|
||||
await service.UpdateProjectAsync(request, userId: context.GetUserId(), cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true } => Results.Ok(),
|
||||
var r when r.HasError<UpdateError>() => Results.BadRequest(r.Errors.ToProblems()),
|
||||
var r => Results.InternalServerError(r.Errors.ToProblems())
|
||||
})
|
||||
.WithDescription("Update project details")
|
||||
.WithName(typeof(UpdateProjectEndpoint).ToEndpointName())
|
||||
.MapToApiVersion(new ApiVersion(1))
|
||||
.Produces(StatusCodes.Status200OK)
|
||||
.Produces<Problems>(StatusCodes.Status400BadRequest)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
.WithDescription("Update project details")
|
||||
.WithName(typeof(UpdateProjectEndpoint).ToEndpointName())
|
||||
.MapToApiVersion(new ApiVersion(1))
|
||||
.Produces(StatusCodes.Status200OK)
|
||||
.Produces<Problems>(StatusCodes.Status400BadRequest)
|
||||
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.WithTags(EndpointTags.Projects);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Projects;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
@@ -14,7 +15,7 @@ public class UpdateProjectStatusEndpoint : IEndpoint
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapPut("api/projects/status", async (UpdateProjectStatusRequest request, HttpContext context,
|
||||
ProjectService service, CancellationToken cancellationToken = default) =>
|
||||
IProjectService service, CancellationToken cancellationToken = default) =>
|
||||
await service.UpdateProjectStatusAsync(request, context.GetUserId(), cancellationToken) switch
|
||||
{
|
||||
{ IsSuccess: true } => Results.Ok(),
|
||||
|
||||
Reference in New Issue
Block a user