using CMSMicroservice.Protobuf.Protos.ProductImages;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.ProductImagesCQ.Commands.CreateNewProductImages;
using CMSMicroservice.Application.ProductImagesCQ.Commands.UpdateProductImages;
using CMSMicroservice.Application.ProductImagesCQ.Commands.DeleteProductImages;
using CMSMicroservice.Application.ProductImagesCQ.Queries.GetProductImages;
using CMSMicroservice.Application.ProductImagesCQ.Queries.GetAllProductImagesByFilter;
namespace CMSMicroservice.WebApi.Services;
public class ProductImagesService : ProductImagesContract.ProductImagesContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public ProductImagesService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewProductImagesResponse> CreateNewProductImages(CreateNewProductImagesRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewProductImagesRequest, CreateNewProductImagesCommand, CreateNewProductImagesResponse>(request, context);
    }
    public override async Task<Empty> UpdateProductImages(UpdateProductImagesRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateProductImagesRequest, UpdateProductImagesCommand>(request, context);
    }
    public override async Task<Empty> DeleteProductImages(DeleteProductImagesRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteProductImagesRequest, DeleteProductImagesCommand>(request, context);
    }
    public override async Task<GetProductImagesResponse> GetProductImages(GetProductImagesRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetProductImagesRequest, GetProductImagesQuery, GetProductImagesResponse>(request, context);
    }
    public override async Task<GetAllProductImagesByFilterResponse> GetAllProductImagesByFilter(GetAllProductImagesByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllProductImagesByFilterRequest, GetAllProductImagesByFilterQuery, GetAllProductImagesByFilterResponse>(request, context);
    }
}
