Skip to content

Commit

Permalink
Moved Categorise endpoint to Wolverine
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Aug 30, 2023
1 parent 62abac3 commit 07ff838
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ await API
.When(
POST,
URI($"/api/agents/{agentId}/incidents/{API.Incident.Id}/category"),
BODY(new CategoriseIncidentRequest(category)),
BODY(new CategoriseIncidentRequest(API.Incident.Id, category)),
HEADERS(IF_MATCH(1))
)
.Then(OK);
Expand Down
1 change: 0 additions & 1 deletion Sample/Helpdesk.Wolverine/Helpdesk.Api/Helpdesk.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Marten.CommandLine" Version="6.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Marten.AspNetCore" Version="6.0.5" />
<PackageReference Include="Marten" Version="6.0.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using Wolverine.Http;
using Wolverine.Marten;
using static Microsoft.AspNetCore.Http.TypedResults;

namespace Helpdesk.Api.Incidents.Categorise;

public static class CategoriseIncidentEndpoint
{
[AggregateHandler]
[WolverinePost("api/agents/{agentId:guid}/incidents/{incidentId:guid}/category")]
public static (IResult, Events) Post(
CategoriseIncidentRequest request,
Incident incident,
[FromRoute] Guid agentId,
[FromRoute] Guid incidentId,
DateTimeOffset now)
{
if (incident.Status == IncidentStatus.Closed)
{
throw new InvalidOperationException("Incident is already closed");
}

return (Ok(), new Events { new IncidentCategorised(incidentId, request.Category, agentId, now) });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ namespace Helpdesk.Api.Incidents;

public static class IncidentsEndpoints
{
[WolverinePost("/api/agents/{agentId:guid}/incidents/{incidentId:guid}/category")]
public static async Task<IResult> CategoriseIncident
(
IDocumentSession documentSession,
Guid incidentId,
Guid agentId,
[FromIfMatchHeader] string eTag,
CategoriseIncidentRequest body,
CancellationToken ct
)
{
await documentSession.GetAndUpdate<Incident>(incidentId, ToExpectedVersion(eTag),
state => Handle(state, new CategoriseIncident(incidentId, body.Category, agentId, Now)), ct);

return Ok();
}

[WolverinePost("/api/agents/{agentId:guid}/incidents/{incidentId:guid}/priority")]
public static async Task<IResult> PrioritiseIncident
(
Expand Down Expand Up @@ -159,6 +142,7 @@ string Description
);

public record CategoriseIncidentRequest(
Guid IncidentId,
IncidentCategory Category
);

Expand Down
1 change: 0 additions & 1 deletion Sample/Helpdesk.Wolverine/Helpdesk.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

var builder = WebApplication.CreateBuilder(args);


builder.Services
.AddEndpointsApiExplorer()
.AddSwaggerGen()
Expand Down

0 comments on commit 07ff838

Please sign in to comment.