using CMSMicroservice.Protobuf.Protos.FactorDetails;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.FactorDetailsCQ.Commands.CreateNewFactorDetails;
using CMSMicroservice.Application.FactorDetailsCQ.Commands.UpdateFactorDetails;
using CMSMicroservice.Application.FactorDetailsCQ.Commands.DeleteFactorDetails;
using CMSMicroservice.Application.FactorDetailsCQ.Queries.GetFactorDetails;
using CMSMicroservice.Application.FactorDetailsCQ.Queries.GetAllFactorDetailsByFilter;
namespace CMSMicroservice.WebApi.Services;
public class FactorDetailsService : FactorDetailsContract.FactorDetailsContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public FactorDetailsService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewFactorDetailsResponse> CreateNewFactorDetails(CreateNewFactorDetailsRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewFactorDetailsRequest, CreateNewFactorDetailsCommand, CreateNewFactorDetailsResponse>(request, context);
    }
    public override async Task<Empty> UpdateFactorDetails(UpdateFactorDetailsRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateFactorDetailsRequest, UpdateFactorDetailsCommand>(request, context);
    }
    public override async Task<Empty> DeleteFactorDetails(DeleteFactorDetailsRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteFactorDetailsRequest, DeleteFactorDetailsCommand>(request, context);
    }
    public override async Task<GetFactorDetailsResponse> GetFactorDetails(GetFactorDetailsRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetFactorDetailsRequest, GetFactorDetailsQuery, GetFactorDetailsResponse>(request, context);
    }
    public override async Task<GetAllFactorDetailsByFilterResponse> GetAllFactorDetailsByFilter(GetAllFactorDetailsByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllFactorDetailsByFilterRequest, GetAllFactorDetailsByFilterQuery, GetAllFactorDetailsByFilterResponse>(request, context);
    }
}
