using CMSMicroservice.Protobuf.Protos.ClubMembershipCycle;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetAllClubMembershipCycleByFilter;
using CMSMicroservice.Application.ClubMembershipCycleCQ.Queries.GetClubMembershipCycleSummary;

namespace CMSMicroservice.WebApi.Services;

public class ClubMembershipCycleService : ClubMembershipCycleContract.ClubMembershipCycleContractBase
{
    private readonly IDispatchRequestToCQRS _dispatch;

    public ClubMembershipCycleService(IDispatchRequestToCQRS dispatch) => _dispatch = dispatch;

    public override Task<GetAllClubMembershipCycleByFilterResponse> GetAllClubMembershipCycleByFilter(
        GetAllClubMembershipCycleByFilterRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetAllClubMembershipCycleByFilterRequest, GetAllClubMembershipCycleByFilterQuery, GetAllClubMembershipCycleByFilterResponse>(request, context);

    public override Task<GetClubMembershipCycleSummaryResponse> GetClubMembershipCycleSummary(
        GetClubMembershipCycleSummaryRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetClubMembershipCycleSummaryRequest, GetClubMembershipCycleSummaryQuery, GetClubMembershipCycleSummaryResponse>(request, context);
}
