Fix task and shift self-assignment features
This commit is contained in:
@@ -42,20 +42,24 @@ public static class ShiftEndpoints
|
||||
|
||||
private static async Task<Ok<ShiftListDto>> GetShifts(
|
||||
ShiftService shiftService,
|
||||
HttpContext httpContext,
|
||||
[FromQuery] DateTimeOffset? from = null,
|
||||
[FromQuery] DateTimeOffset? to = null,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
var result = await shiftService.GetShiftsAsync(from, to, page, pageSize);
|
||||
var externalUserId = httpContext.User.FindFirst("sub")?.Value;
|
||||
var result = await shiftService.GetShiftsAsync(from, to, page, pageSize, externalUserId);
|
||||
return TypedResults.Ok(result);
|
||||
}
|
||||
|
||||
private static async Task<Results<Ok<ShiftDetailDto>, NotFound>> GetShift(
|
||||
Guid id,
|
||||
ShiftService shiftService)
|
||||
ShiftService shiftService,
|
||||
HttpContext httpContext)
|
||||
{
|
||||
var result = await shiftService.GetShiftByIdAsync(id);
|
||||
var externalUserId = httpContext.User.FindFirst("sub")?.Value;
|
||||
var result = await shiftService.GetShiftByIdAsync(id, externalUserId);
|
||||
|
||||
if (result == null)
|
||||
return TypedResults.NotFound();
|
||||
@@ -85,9 +89,11 @@ public static class ShiftEndpoints
|
||||
private static async Task<Results<Ok<ShiftDetailDto>, NotFound, Conflict<string>>> UpdateShift(
|
||||
Guid id,
|
||||
UpdateShiftRequest request,
|
||||
ShiftService shiftService)
|
||||
ShiftService shiftService,
|
||||
HttpContext httpContext)
|
||||
{
|
||||
var (shift, error, isConflict) = await shiftService.UpdateShiftAsync(id, request);
|
||||
var externalUserId = httpContext.User.FindFirst("sub")?.Value;
|
||||
var (shift, error, isConflict) = await shiftService.UpdateShiftAsync(id, request, externalUserId);
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user