Generator Changes at 11/12/2025 1:32:03 AM +03:30
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.ProductImagesCQ.Queries.GetProductImages;
|
||||
public record GetProductImagesQuery : IRequest<GetProductImagesResponseDto>
|
||||
{
|
||||
//
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace CMSMicroservice.Application.ProductImagesCQ.Queries.GetProductImages;
|
||||
public class GetProductImagesQueryHandler : IRequestHandler<GetProductImagesQuery, GetProductImagesResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetProductImagesQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetProductImagesResponseDto> Handle(GetProductImagesQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.ProductImagess
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.ProjectToType<GetProductImagesResponseDto>()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return response ?? throw new NotFoundException(nameof(ProductImages), request.Id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.ProductImagesCQ.Queries.GetProductImages;
|
||||
public class GetProductImagesQueryValidator : AbstractValidator<GetProductImagesQuery>
|
||||
{
|
||||
public GetProductImagesQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetProductImagesQuery>.CreateWithOptions((GetProductImagesQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace CMSMicroservice.Application.ProductImagesCQ.Queries.GetProductImages;
|
||||
public class GetProductImagesResponseDto
|
||||
{
|
||||
//
|
||||
public long Id { get; set; }
|
||||
//
|
||||
public string Title { get; set; }
|
||||
//
|
||||
public string ImagePath { get; set; }
|
||||
//
|
||||
public string ImageThumbnailPath { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user