Orders work...

This commit is contained in:
lumijiez
2025-06-26 02:51:14 +03:00
parent c7dcbc1926
commit c137a03a0a
6 changed files with 805 additions and 12 deletions

View File

@@ -12,7 +12,6 @@ public class CreateOrderCommand : IRequest<OrderDto>
public int Quantity { get; set; }
public Guid ProductId { get; set; }
public Guid ProductVariantId { get; set; }
public string? ComposingImageUrl { get; set; }
public string[]? OriginalImageUrls { get; set; } = [];
public string? CustomizationImageUrl { get; set; } = null!;
public string? CustomizationDescription { get; set; } = null!;

View File

@@ -17,7 +17,7 @@ public class GetProductById(
CancellationToken cancellationToken)
{
var product = await unitOfWork.ProductRepository
.GetByIdAsync(request.ProductId, cancellationToken);
.GetByIdWithCategoryAsync(request.ProductId, cancellationToken);
if (product == null)
return null;

View File

@@ -25,13 +25,6 @@ public class CreateOrderCommandValidator : AbstractValidator<CreateOrderCommand>
.NotEmpty()
.WithMessage("Address ID is required.");
RuleFor(x => x.ComposingImageUrl)
.MaximumLength(2048)
.WithMessage("Composing image URL must not exceed 2048 characters.")
.Must(BeValidUrl)
.When(x => !string.IsNullOrEmpty(x.ComposingImageUrl))
.WithMessage("Composing image URL must be a valid URL.");
RuleFor(x => x.CustomizationImageUrl)
.MaximumLength(2048)
.WithMessage("Customization image URL must not exceed 2048 characters.")

View File

@@ -10,11 +10,12 @@ namespace Imprink.WebApi.Controllers;
[Route("/api/products/variants")]
public class ProductVariantsController(IMediator mediator) : ControllerBase
{
[HttpGet]
[HttpGet("{id:guid}")]
[AllowAnonymous]
public async Task<ActionResult<IEnumerable<ProductVariantDto>>> GetProductVariants(
[FromQuery] GetProductVariantsQuery query)
Guid id)
{
var query = new GetProductVariantsQuery { ProductId = id };
return Ok(await mediator.Send(query));
}

View File

@@ -23,7 +23,7 @@ public class ProductsController(IMediator mediator) : ControllerBase
[HttpGet("{id:guid}")]
[AllowAnonymous]
public async Task<ActionResult<PagedResultDto<ProductDto>>> GetProductById(
public async Task<ActionResult<ProductDto>> GetProductById(
Guid id,
CancellationToken cancellationToken)
{