using CMSMicroservice.Protobuf.Protos.UserPackagePurchase;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetCustomerPackagePurchaseRollup;

namespace CMSMicroservice.WebApi.Services;

public class UserPackagePurchaseService : UserPackagePurchaseContract.UserPackagePurchaseContractBase
{
    private readonly IDispatchRequestToCQRS _dispatch;

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

    public override Task<GetAllUserPackagePurchaseByFilterResponse> GetAllUserPackagePurchaseByFilter(
        GetAllUserPackagePurchaseByFilterRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetAllUserPackagePurchaseByFilterRequest, GetAllUserPackagePurchaseByFilterQuery, GetAllUserPackagePurchaseByFilterResponse>(request, context);

    public override Task<GetUserPackagePurchaseSummaryResponse> GetUserPackagePurchaseSummary(
        GetUserPackagePurchaseSummaryRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetUserPackagePurchaseSummaryRequest, GetUserPackagePurchaseSummaryQuery, GetUserPackagePurchaseSummaryResponse>(request, context);

    public override Task<GetCustomerPackagePurchaseRollupResponse> GetCustomerPackagePurchaseRollup(
        GetCustomerPackagePurchaseRollupRequest request, ServerCallContext context) =>
        _dispatch.Handle<GetCustomerPackagePurchaseRollupRequest, GetCustomerPackagePurchaseRollupQuery, GetCustomerPackagePurchaseRollupResponse>(request, context);
}
