Изображения в услугах, поиске, возможность открыть карточку услуги
This commit is contained in:
@@ -62,5 +62,49 @@ public static class CatalogEndpoints
|
||||
})
|
||||
.WithName("GetOfferById")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Получить детали услуги по ID", Description = "Возвращает полную информацию об услуге." });
|
||||
|
||||
protectedOffersGroup.MapPut("/offers/{id:guid}", async (Guid id, [FromBody] UpdateOfferPayload payload, ISender sender) =>
|
||||
{
|
||||
var command = new UpdateOfferCommand(id, payload.Title, payload.Description, payload.Price.Amount, payload.Price.Type, payload.Attributes, payload.Images);
|
||||
await sender.Send(command);
|
||||
return Results.NoContent();
|
||||
})
|
||||
.WithName("UpdateOffer")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Обновить услугу" });
|
||||
|
||||
protectedOffersGroup.MapPatch("/offers/{id:guid}/toggle", async (Guid id, ISender sender) =>
|
||||
{
|
||||
var isActive = await sender.Send(new ToggleOfferStatusCommand(id));
|
||||
return Results.Ok(new { IsActive = isActive });
|
||||
})
|
||||
.WithName("ToggleOfferStatus")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Приостановить/активировать услугу" });
|
||||
|
||||
protectedOffersGroup.MapDelete("/offers/{id:guid}", async (Guid id, ISender sender) =>
|
||||
{
|
||||
await sender.Send(new DeleteOfferCommand(id));
|
||||
return Results.NoContent();
|
||||
})
|
||||
.WithName("DeleteOffer")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Удалить услугу" });
|
||||
|
||||
protectedOffersGroup.MapPost("/offers/image", async (IFormFile file, ISender sender) =>
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
await file.CopyToAsync(ms);
|
||||
var url = await sender.Send(new UploadOfferImageCommand(ms.ToArray(), file.FileName));
|
||||
return Results.Ok(new { url });
|
||||
})
|
||||
.WithName("UploadOfferImage")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Загрузить изображение для услуги" })
|
||||
.DisableAntiforgery();
|
||||
}
|
||||
}
|
||||
|
||||
public record UpdateOfferPayload(
|
||||
string Title,
|
||||
string Description,
|
||||
PricePayload Price,
|
||||
Dictionary<string, string>? Attributes,
|
||||
List<string>? Images);
|
||||
public record PricePayload(decimal Amount, int Type);
|
||||
|
||||
Reference in New Issue
Block a user