using CMSMicroservice.Protobuf.Protos.UserContract;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserContractCQ.Commands.CreateNewUserContract;
using CMSMicroservice.Application.UserContractCQ.Commands.UpdateUserContract;
using CMSMicroservice.Application.UserContractCQ.Commands.DeleteUserContract;
using CMSMicroservice.Application.UserContractCQ.Queries.GetUserContract;
using CMSMicroservice.Application.UserContractCQ.Queries.GetAllUserContractByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserContractService : UserContractContract.UserContractContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public UserContractService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewUserContractResponse> CreateNewUserContract(CreateNewUserContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewUserContractRequest, CreateNewUserContractCommand, CreateNewUserContractResponse>(request, context);
    }
    public override async Task<Empty> UpdateUserContract(UpdateUserContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateUserContractRequest, UpdateUserContractCommand>(request, context);
    }
    public override async Task<Empty> DeleteUserContract(DeleteUserContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteUserContractRequest, DeleteUserContractCommand>(request, context);
    }
    public override async Task<GetUserContractResponse> GetUserContract(GetUserContractRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetUserContractRequest, GetUserContractQuery, GetUserContractResponse>(request, context);
    }
    public override async Task<GetAllUserContractByFilterResponse> GetAllUserContractByFilter(GetAllUserContractByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllUserContractByFilterRequest, GetAllUserContractByFilterQuery, GetAllUserContractByFilterResponse>(request, context);
    }
}
