using CMSMicroservice.Protobuf.Protos.Contract;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.ContractCQ.Commands.CreateNewContract;
using CMSMicroservice.Application.ContractCQ.Commands.UpdateContract;
using CMSMicroservice.Application.ContractCQ.Commands.DeleteContract;
using CMSMicroservice.Application.ContractCQ.Queries.GetContract;
using CMSMicroservice.Application.ContractCQ.Queries.GetAllContractByFilter;
namespace CMSMicroservice.WebApi.Services;
public class ContractService : ContractContract.ContractContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public ContractService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewContractResponse> CreateNewContract(CreateNewContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewContractRequest, CreateNewContractCommand, CreateNewContractResponse>(request, context);
    }
    public override async Task<Empty> UpdateContract(UpdateContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateContractRequest, UpdateContractCommand>(request, context);
    }
    public override async Task<Empty> DeleteContract(DeleteContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteContractRequest, DeleteContractCommand>(request, context);
    }
    public override async Task<GetContractResponse> GetContract(GetContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetContractRequest, GetContractQuery, GetContractResponse>(request, context);
    }
    public override async Task<GetAllContractByFilterResponse> GetAllContractByFilter(GetAllContractByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllContractByFilterRequest, GetAllContractByFilterQuery, GetAllContractByFilterResponse>(request, context);
    }
}
