using CMSMicroservice.Protobuf.Protos.UserRole;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserRoleCQ.Commands.CreateNewUserRole;
using CMSMicroservice.Application.UserRoleCQ.Commands.UpdateUserRole;
using CMSMicroservice.Application.UserRoleCQ.Commands.DeleteUserRole;
using CMSMicroservice.Application.UserRoleCQ.Queries.GetUserRole;
using CMSMicroservice.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserRoleService : UserRoleContract.UserRoleContractBase
{
    private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;

    public UserRoleService(IDispatchRequestToCQRS dispatchRequestToCQRS)
    {
        _dispatchRequestToCQRS = dispatchRequestToCQRS;
    }
    public override async Task<CreateNewUserRoleResponse> CreateNewUserRole(CreateNewUserRoleRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<CreateNewUserRoleRequest, CreateNewUserRoleCommand, CreateNewUserRoleResponse>(request, context);
    }
    public override async Task<Empty> UpdateUserRole(UpdateUserRoleRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<UpdateUserRoleRequest, UpdateUserRoleCommand>(request, context);
    }
    public override async Task<Empty> DeleteUserRole(DeleteUserRoleRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<DeleteUserRoleRequest, DeleteUserRoleCommand>(request, context);
    }
    public override async Task<GetUserRoleResponse> GetUserRole(GetUserRoleRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetUserRoleRequest, GetUserRoleQuery, GetUserRoleResponse>(request, context);
    }
    public override async Task<GetAllUserRoleByFilterResponse> GetAllUserRoleByFilter(GetAllUserRoleByFilterRequest request, ServerCallContext context)
    {
        return await _dispatchRequestToCQRS.Handle<GetAllUserRoleByFilterRequest, GetAllUserRoleByFilterQuery, GetAllUserRoleByFilterResponse>(request, context);
    }
}
