using CMSMicroservice.Protobuf.Protos.ProductTag;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.ProductTagCQ.Commands.CreateNewProductTag;
using CMSMicroservice.Application.ProductTagCQ.Commands.UpdateProductTag;
using CMSMicroservice.Application.ProductTagCQ.Commands.DeleteProductTag;
using CMSMicroservice.Application.ProductTagCQ.Queries.GetProductTag;
using CMSMicroservice.Application.ProductTagCQ.Queries.GetAllProductTagByFilter;
namespace CMSMicroservice.WebApi.Services;
public class ProductTagService : ProductTagContract.ProductTagContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public ProductTagService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewProductTagResponse> CreateNewProductTag(CreateNewProductTagRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewProductTagRequest, CreateNewProductTagCommand, CreateNewProductTagResponse>(request, context);
    }
    public override async Task<Empty> UpdateProductTag(UpdateProductTagRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateProductTagRequest, UpdateProductTagCommand>(request, context);
    }
    public override async Task<Empty> DeleteProductTag(DeleteProductTagRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteProductTagRequest, DeleteProductTagCommand>(request, context);
    }
    public override async Task<GetProductTagResponse> GetProductTag(GetProductTagRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetProductTagRequest, GetProductTagQuery, GetProductTagResponse>(request, context);
    }
    public override async Task<GetAllProductTagByFilterResponse> GetAllProductTagByFilter(GetAllProductTagByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllProductTagByFilterRequest, GetAllProductTagByFilterQuery, GetAllProductTagByFilterResponse>(request, context);
    }
}
