| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using ClutterStock.Contracts.Rooms; |
| | | 3 | | using ClutterStock.Domain.Abstractions; |
| | | 4 | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | 5 | | using Microsoft.AspNetCore.Mvc; |
| | | 6 | | |
| | | 7 | | namespace ClutterStock.Domain.Features.Rooms.UpdateRoom; |
| | | 8 | | |
| | | 9 | | [HttpMethod(HttpVerb.Put)] |
| | | 10 | | [OpenApiDescription("Updates an existing room by id.")] |
| | | 11 | | public class UpdateRoomEndpoint : IEndpoint |
| | | 12 | | { |
| | 3 | 13 | | public static string Route => "/rooms/{id}"; |
| | | 14 | | |
| | 3 | 15 | | public static Delegate Handler => (Func<int, UpdateRoomRequest, IUpdateRoomCommandHandler, CancellationToken, Task<R |
| | | 16 | | |
| | | 17 | | private static async Task<Results<Ok<RoomResponse>, NotFound>> Handle([FromRoute, Range(1, int.MaxValue)] int id, |
| | | 18 | | [FromBody] UpdateRoomRequest request, |
| | | 19 | | IUpdateRoomCommandHandler handler, |
| | | 20 | | CancellationToken cancellationToken) |
| | | 21 | | { |
| | 2 | 22 | | var command = new IUpdateRoomCommandHandler.Command(id, request.LocationId, request.Name, request.Description); |
| | 2 | 23 | | return await handler.HandleAsync(command, cancellationToken); |
| | 2 | 24 | | } |
| | | 25 | | } |