-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Get endpoints to dedicated class and used Wolverine for them
- Loading branch information
1 parent
5674764
commit cc61669
Showing
3 changed files
with
58 additions
and
34 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/IncidentGetEndpoints.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,58 @@ | ||
using Helpdesk.Api.Incidents.GetCustomerIncidentsSummary; | ||
using Helpdesk.Api.Incidents.GetIncidentDetails; | ||
using Helpdesk.Api.Incidents.GetIncidentHistory; | ||
using Helpdesk.Api.Incidents.GetIncidentShortInfo; | ||
using Marten; | ||
using Marten.AspNetCore; | ||
using Marten.Pagination; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Wolverine.Http; | ||
|
||
namespace Helpdesk.Api.Incidents; | ||
|
||
public class IncidentGetEndpoints | ||
{ | ||
[WolverineGet("/api/customers/{customerId:guid}/incidents/")] | ||
public Task<IPagedList<IncidentShortInfo>> GetCustomerIncidents | ||
(IQuerySession querySession, Guid customerId, [FromQuery] int? pageNumber, [FromQuery] int? pageSize, | ||
CancellationToken ct) => | ||
querySession.Query<IncidentShortInfo>().Where(i => i.CustomerId == customerId) | ||
.ToPagedListAsync(pageNumber ?? 1, pageSize ?? 10, ct); | ||
|
||
// That for some reason doesn't work for me | ||
// [WolverineGet("/api/incidents/{incidentId:guid}")] | ||
// public Task GetIncidentById([FromQuery] Guid incidentId, IQuerySession querySession, HttpContext context) => | ||
// querySession.Json.WriteById<IncidentDetails>(incidentId, context); | ||
|
||
[WolverineGet("/api/incidents/{incidentId:guid}")] | ||
public Task<IncidentDetails?> GetIncidentById([FromQuery] Guid incidentId, IQuerySession querySession, | ||
CancellationToken ct) => | ||
querySession.LoadAsync<IncidentDetails>(incidentId, ct); | ||
|
||
// That for some reason doesn't work for me | ||
// [WolverineGet("/api/incidents/{incidentId:guid}/history")] | ||
// public Task GetIncidentHistory([FromQuery]Guid incidentId, HttpContext context, IQuerySession querySession) => | ||
// querySession.Query<IncidentHistory>().Where(i => i.IncidentId == incidentId).WriteArray(context); | ||
|
||
[WolverineGet("/api/incidents/{incidentId:guid}/history")] | ||
public Task<IReadOnlyList<IncidentHistory>> GetIncidentHistory( | ||
[FromQuery] Guid incidentId, | ||
IQuerySession querySession, | ||
CancellationToken ct | ||
) => | ||
querySession.Query<IncidentHistory>().Where(i => i.IncidentId == incidentId).ToListAsync(ct); | ||
|
||
// That for some reason doesn't work for me | ||
// [WolverineGet("/api/customers/{customerId:guid}/incidents/incidents-summary")] | ||
// public Task GetCustomerIncidentsSummary([FromQuery] Guid customerId, HttpContext context, | ||
// IQuerySession querySession) => | ||
// querySession.Json.WriteById<CustomerIncidentsSummary>(customerId, context); | ||
|
||
[WolverineGet("/api/customers/{customerId:guid}/incidents/incidents-summary")] | ||
public Task GetCustomerIncidentsSummary( | ||
[FromQuery] Guid customerId, | ||
IQuerySession querySession, | ||
CancellationToken ct | ||
) => | ||
querySession.LoadAsync<CustomerIncidentsSummary>(customerId, ct); | ||
} |
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