using CMSMicroservice.Protobuf.Protos.ProductCategory;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.ProductCategoryCQ.Commands.CreateNewProductCategory;
using CMSMicroservice.Application.ProductCategoryCQ.Commands.UpdateProductCategory;
using CMSMicroservice.Application.ProductCategoryCQ.Commands.DeleteProductCategory;
using CMSMicroservice.Application.ProductCategoryCQ.Queries.GetProductCategory;
using CMSMicroservice.Application.ProductCategoryCQ.Queries.GetAllProductCategoryByFilter;
namespace CMSMicroservice.WebApi.Services;
public class ProductCategoryService : ProductCategoryContract.ProductCategoryContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public ProductCategoryService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewProductCategoryResponse> CreateNewProductCategory(CreateNewProductCategoryRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewProductCategoryRequest, CreateNewProductCategoryCommand, CreateNewProductCategoryResponse>(request, context);
    }
    public override async Task<Empty> UpdateProductCategory(UpdateProductCategoryRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateProductCategoryRequest, UpdateProductCategoryCommand>(request, context);
    }
    public override async Task<Empty> DeleteProductCategory(DeleteProductCategoryRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteProductCategoryRequest, DeleteProductCategoryCommand>(request, context);
    }
    public override async Task<GetProductCategoryResponse> GetProductCategory(GetProductCategoryRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetProductCategoryRequest, GetProductCategoryQuery, GetProductCategoryResponse>(request, context);
    }
    public override async Task<GetAllProductCategoryByFilterResponse> GetAllProductCategoryByFilter(GetAllProductCategoryByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllProductCategoryByFilterRequest, GetAllProductCategoryByFilterQuery, GetAllProductCategoryByFilterResponse>(request, context);
    }
}
