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