From 62abac36da9de853450d4db1e75d9ab18812b98a Mon Sep 17 00:00:00 2001 From: Oskar Dudycz Date: Tue, 29 Aug 2023 15:51:27 +0200 Subject: [PATCH] Moved LogIncident feature to own LogIncident endpoint --- .../Helpdesk.Api/Incidents/IncidentService.cs | 7 ----- .../Incidents/IncidentsEndpoints.cs | 13 --------- .../Incidents/Logging/LogIncidentEndpoint.cs | 27 +++++++++++++++++++ .../Properties/launchSettings.json | 2 +- 4 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/Logging/LogIncidentEndpoint.cs diff --git a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentService.cs b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentService.cs index c560ba759..32bbcbaa2 100644 --- a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentService.cs +++ b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentService.cs @@ -62,13 +62,6 @@ DateTimeOffset Now internal static class IncidentService { - public static IncidentLogged Handle(LogIncident command) - { - var (incidentId, customerId, contact, description, loggedBy, now) = command; - - return new IncidentLogged(incidentId, customerId, contact, description, loggedBy, now); - } - public static IncidentCategorised Handle(Incident current, CategoriseIncident command) { if (current.Status == IncidentStatus.Closed) diff --git a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentsEndpoints.cs b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentsEndpoints.cs index 4abda386f..fce908689 100644 --- a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentsEndpoints.cs +++ b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentsEndpoints.cs @@ -13,19 +13,6 @@ namespace Helpdesk.Api.Incidents; public static class IncidentsEndpoints { - [WolverinePost("/api/customers/{customerId:guid}/incidents")] - public static (CreationResponse, IStartStream) LogIncident(Guid customerId, LogIncidentRequest body) - { - var (contact, description) = body; - var incidentId = CombGuidIdGeneration.NewGuid(); - - var result = Handle(new LogIncident(incidentId, customerId, contact, description, customerId, Now)); - - var startStream = MartenOps.StartStream(result); - - return (new CreationResponse($"/api/incidents/{startStream.StreamId}"), startStream); - } - [WolverinePost("/api/agents/{agentId:guid}/incidents/{incidentId:guid}/category")] public static async Task CategoriseIncident ( diff --git a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/Logging/LogIncidentEndpoint.cs b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/Logging/LogIncidentEndpoint.cs new file mode 100644 index 000000000..2c4a9ee6d --- /dev/null +++ b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/Logging/LogIncidentEndpoint.cs @@ -0,0 +1,27 @@ +using JasperFx.Core; +using Wolverine.Http; +using Wolverine.Marten; + +namespace Helpdesk.Api.Incidents.Logging; + +public static class LogIncidentEndpoint +{ + [WolverinePost("/api/customers/{customerId:guid}/incidents")] + public static (CreationResponse, IStartStream) LogIncident( + Guid customerId, + LogIncidentRequest request, + DateTimeOffset now + ) + { + var (contact, description) = request; + var incidentId = CombGuidIdGeneration.NewGuid(); + + var @event = new IncidentLogged(incidentId, customerId, contact, description, customerId, now); + + return ( + new CreationResponse($"/api/incidents/{incidentId}"), + new StartStream(incidentId, @event) + ); + } + +} diff --git a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Properties/launchSettings.json b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Properties/launchSettings.json index 01dd421e9..912842140 100644 --- a/Sample/Helpdesk.Wolverine/Helpdesk.Api/Properties/launchSettings.json +++ b/Sample/Helpdesk.Wolverine/Helpdesk.Api/Properties/launchSettings.json @@ -1,6 +1,6 @@ { "profiles": { - "Helpdesk.Api": { + "Helpdesk.Wolverine.Api": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true,