Skip to content

Commit

Permalink
Moved LogIncident feature to own LogIncident endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Aug 29, 2023
1 parent b8ff999 commit af61453
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Incident>(result);

return (new CreationResponse($"/api/incidents/{startStream.StreamId}"), startStream);
}

[WolverinePost("/api/agents/{agentId:guid}/incidents/{incidentId:guid}/category")]
public static async Task<IResult> CategoriseIncident
(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using JasperFx.Core;
using Wolverine.Http;
using Wolverine.Marten;

namespace Helpdesk.Api.Incidents.LoggingIncidents;

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<Incident>(incidentId, @event)
);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"Helpdesk.Api": {
"Helpdesk.Wolverine.Api": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
Expand Down

0 comments on commit af61453

Please sign in to comment.