-
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a05d540
commit b9baa60
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/Unresolving/Unresolve.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Wolverine.Http; | ||
using Wolverine.Marten; | ||
using static Microsoft.AspNetCore.Http.TypedResults; | ||
|
||
namespace Helpdesk.Api.Incidents.Unresolving; | ||
|
||
public static class UnResolveEndpoint | ||
{ | ||
[AggregateHandler] | ||
[WolverinePost("/api/agents/{agentId:guid}/incidents/{incidentId:guid}/unresolve")] | ||
public static (IResult, Events) Unresolve | ||
( | ||
UnesolveIncident command, | ||
Incident incident, | ||
DateTimeOffset now | ||
) | ||
{ | ||
if (incident.Status is IncidentStatus.Closed) | ||
throw new InvalidOperationException("Cannot unresolve already closed incident"); | ||
|
||
if (incident.HasOutstandingResponseToCustomer) | ||
throw new InvalidOperationException("Cannot resolve incident that has outstanding responses to customer"); | ||
|
||
return (Ok(), [new IncidentUnresolved(incident.Id, command.Reason, command.AgentId, now)]); | ||
} | ||
} | ||
|
||
public record UnesolveIncident( | ||
Guid IncidentId, | ||
Guid AgentId, | ||
string Reason, | ||
int Version | ||
); |