diff --git a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj index 56200bf..1871b09 100644 --- a/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj +++ b/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj @@ -43,6 +43,11 @@ + + + + + diff --git a/src/CMSMicroservice.Protobuf/Protos/clubmembership.proto b/src/CMSMicroservice.Protobuf/Protos/clubmembership.proto new file mode 100644 index 0000000..8f7d69e --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/clubmembership.proto @@ -0,0 +1,166 @@ +syntax = "proto3"; + +package clubmembership; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ClubMembership"; + +service ClubMembershipContract +{ + rpc ActivateClubMembership(ActivateClubMembershipRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/ClubMembership/Activate" + body: "*" + }; + }; + rpc DeactivateClubMembership(DeactivateClubMembershipRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/ClubMembership/Deactivate" + body: "*" + }; + }; + rpc AssignFeatureToMembership(AssignFeatureToMembershipRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/ClubMembership/AssignFeature" + body: "*" + }; + }; + rpc GetClubMembership(GetClubMembershipRequest) returns (GetClubMembershipResponse){ + option (google.api.http) = { + get: "/ClubMembership/Get" + }; + }; + rpc GetAllClubMemberships(GetAllClubMembershipsRequest) returns (GetAllClubMembershipsResponse){ + option (google.api.http) = { + get: "/ClubMembership/GetAll" + }; + }; + rpc GetClubMembershipHistory(GetClubMembershipHistoryRequest) returns (GetClubMembershipHistoryResponse){ + option (google.api.http) = { + get: "/ClubMembership/GetHistory" + }; + }; +} + +// Activate Command +message ActivateClubMembershipRequest +{ + int64 user_id = 1; + int64 package_id = 2; + google.protobuf.StringValue activation_code = 3; + int32 duration_months = 4; +} + +// Deactivate Command +message DeactivateClubMembershipRequest +{ + int64 user_id = 1; + string reason = 2; +} + +// AssignFeature Command +message AssignFeatureToMembershipRequest +{ + int64 user_id = 1; + int64 product_id = 2; + google.protobuf.Int32Value quantity = 3; + google.protobuf.Int32Value duration_days = 4; +} + +// Get Query +message GetClubMembershipRequest +{ + int64 user_id = 1; +} + +message GetClubMembershipResponse +{ + int64 id = 1; + int64 user_id = 2; + int64 package_id = 3; + string package_name = 4; + string activation_code = 5; + google.protobuf.Timestamp activated_at = 6; + google.protobuf.Timestamp expires_at = 7; + bool is_active = 8; + google.protobuf.Timestamp created = 9; + repeated MembershipFeatureModel features = 10; +} + +message MembershipFeatureModel +{ + int64 product_id = 1; + string product_name = 2; + int32 quantity = 3; + google.protobuf.Timestamp expires_at = 4; + bool is_active = 5; +} + +// GetAll Query +message GetAllClubMembershipsRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.Int64Value package_id = 2; + google.protobuf.BoolValue is_active = 3; + google.protobuf.BoolValue is_expired = 4; + int32 page_index = 5; + int32 page_size = 6; +} + +message GetAllClubMembershipsResponse +{ + messages.MetaData meta_data = 1; + repeated ClubMembershipModel models = 2; +} + +message ClubMembershipModel +{ + int64 id = 1; + int64 user_id = 2; + string user_name = 3; + int64 package_id = 4; + string package_name = 5; + string activation_code = 6; + google.protobuf.Timestamp activated_at = 7; + google.protobuf.Timestamp expires_at = 8; + bool is_active = 9; + bool is_expired = 10; + google.protobuf.Timestamp created = 11; +} + +// GetHistory Query +message GetClubMembershipHistoryRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.Int64Value package_id = 2; + int32 page_index = 3; + int32 page_size = 4; +} + +message GetClubMembershipHistoryResponse +{ + messages.MetaData meta_data = 1; + repeated ClubMembershipHistoryModel models = 2; +} + +message ClubMembershipHistoryModel +{ + int64 id = 1; + int64 club_membership_id = 2; + int64 user_id = 3; + google.protobuf.Int64Value old_package_id = 4; + google.protobuf.Int64Value new_package_id = 5; + google.protobuf.Timestamp old_activated_at = 6; + google.protobuf.Timestamp new_activated_at = 7; + google.protobuf.Timestamp old_expires_at = 8; + google.protobuf.Timestamp new_expires_at = 9; + int32 action = 10; // ClubMembershipAction enum + string performed_by = 11; + string reason = 12; + google.protobuf.Timestamp created = 13; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/commission.proto b/src/CMSMicroservice.Protobuf/Protos/commission.proto new file mode 100644 index 0000000..cbe7907 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/commission.proto @@ -0,0 +1,220 @@ +syntax = "proto3"; + +package commission; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Commission"; + +service CommissionContract +{ + // Commands + rpc CalculateWeeklyBalances(CalculateWeeklyBalancesRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Commission/CalculateWeeklyBalances" + body: "*" + }; + }; + rpc CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Commission/CalculateWeeklyPool" + body: "*" + }; + }; + rpc ProcessUserPayouts(ProcessUserPayoutsRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Commission/ProcessPayouts" + body: "*" + }; + }; + rpc RequestWithdrawal(RequestWithdrawalRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Commission/RequestWithdrawal" + body: "*" + }; + }; + rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Commission/ProcessWithdrawal" + body: "*" + }; + }; + + // Queries + rpc GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest) returns (GetWeeklyCommissionPoolResponse){ + option (google.api.http) = { + get: "/Commission/GetWeeklyPool" + }; + }; + rpc GetUserCommissionPayouts(GetUserCommissionPayoutsRequest) returns (GetUserCommissionPayoutsResponse){ + option (google.api.http) = { + get: "/Commission/GetUserPayouts" + }; + }; + rpc GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest) returns (GetCommissionPayoutHistoryResponse){ + option (google.api.http) = { + get: "/Commission/GetPayoutHistory" + }; + }; + rpc GetUserWeeklyBalances(GetUserWeeklyBalancesRequest) returns (GetUserWeeklyBalancesResponse){ + option (google.api.http) = { + get: "/Commission/GetUserWeeklyBalances" + }; + }; +} + +// ============ Commands ============ + +// CalculateWeeklyBalances Command +message CalculateWeeklyBalancesRequest +{ + string week_number = 1; // Format: "YYYY-Www" (e.g., "2025-W01") + bool force_recalculate = 2; +} + +// CalculateWeeklyCommissionPool Command +message CalculateWeeklyCommissionPoolRequest +{ + string week_number = 1; +} + +// ProcessUserPayouts Command +message ProcessUserPayoutsRequest +{ + string week_number = 1; + bool force_reprocess = 2; +} + +// RequestWithdrawal Command +message RequestWithdrawalRequest +{ + int64 payout_id = 1; + int32 withdrawal_method = 2; // WithdrawalMethod enum: Cash=0, Diamond=1 + google.protobuf.StringValue iban_number = 3; // Required for Cash method +} + +// ProcessWithdrawal Command +message ProcessWithdrawalRequest +{ + int64 payout_id = 1; + bool is_approved = 2; + google.protobuf.StringValue reason = 3; // Required for rejection +} + +// ============ Queries ============ + +// GetWeeklyCommissionPool Query +message GetWeeklyCommissionPoolRequest +{ + string week_number = 1; +} + +message GetWeeklyCommissionPoolResponse +{ + int64 id = 1; + string week_number = 2; + int64 total_pool_amount = 3; // Rials + int32 total_balances = 4; + int64 value_per_balance = 5; // Rials per balance + bool is_calculated = 6; + google.protobuf.Timestamp calculated_at = 7; + google.protobuf.Timestamp created = 8; +} + +// GetUserCommissionPayouts Query +message GetUserCommissionPayoutsRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.Int32Value status = 2; // CommissionPayoutStatus enum + google.protobuf.StringValue week_number = 3; + int32 page_index = 4; + int32 page_size = 5; +} + +message GetUserCommissionPayoutsResponse +{ + messages.MetaData meta_data = 1; + repeated UserCommissionPayoutModel models = 2; +} + +message UserCommissionPayoutModel +{ + int64 id = 1; + int64 user_id = 2; + string user_name = 3; + string week_number = 4; + int32 balances_earned = 5; + int64 value_per_balance = 6; + int64 total_amount = 7; + int32 status = 8; // CommissionPayoutStatus enum + google.protobuf.Int32Value withdrawal_method = 9; + string iban_number = 10; + google.protobuf.Timestamp created = 11; + google.protobuf.Timestamp last_modified = 12; +} + +// GetCommissionPayoutHistory Query +message GetCommissionPayoutHistoryRequest +{ + google.protobuf.Int64Value payout_id = 1; + google.protobuf.Int64Value user_id = 2; + google.protobuf.StringValue week_number = 3; + int32 page_index = 4; + int32 page_size = 5; +} + +message GetCommissionPayoutHistoryResponse +{ + messages.MetaData meta_data = 1; + repeated CommissionPayoutHistoryModel models = 2; +} + +message CommissionPayoutHistoryModel +{ + int64 id = 1; + int64 payout_id = 2; + int64 user_id = 3; + string week_number = 4; + int64 amount_before = 5; + int64 amount_after = 6; + int32 old_status = 7; // CommissionPayoutStatus enum + int32 new_status = 8; + int32 action = 9; // CommissionPayoutAction enum + string performed_by = 10; + string reason = 11; + google.protobuf.Timestamp created = 12; +} + +// GetUserWeeklyBalances Query +message GetUserWeeklyBalancesRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.StringValue week_number = 2; + bool only_active = 3; // Only non-expired balances + int32 page_index = 4; + int32 page_size = 5; +} + +message GetUserWeeklyBalancesResponse +{ + messages.MetaData meta_data = 1; + repeated UserWeeklyBalanceModel models = 2; +} + +message UserWeeklyBalanceModel +{ + int64 id = 1; + int64 user_id = 2; + string week_number = 3; + int32 left_leg_balances = 4; + int32 right_leg_balances = 5; + int32 total_balances = 6; + int64 weekly_pool_contribution = 7; + google.protobuf.Timestamp calculated_at = 8; + bool is_expired = 9; + google.protobuf.Timestamp created = 10; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/configuration.proto b/src/CMSMicroservice.Protobuf/Protos/configuration.proto new file mode 100644 index 0000000..380d6df --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/configuration.proto @@ -0,0 +1,133 @@ +syntax = "proto3"; + +package configuration; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Configuration"; + +service ConfigurationContract +{ + rpc CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Configuration/CreateOrUpdate" + body: "*" + }; + }; + rpc DeactivateConfiguration(DeactivateConfigurationRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/Configuration/Deactivate" + body: "*" + }; + }; + rpc GetConfigurationByKey(GetConfigurationByKeyRequest) returns (GetConfigurationByKeyResponse){ + option (google.api.http) = { + get: "/Configuration/GetByKey" + }; + }; + rpc GetAllConfigurations(GetAllConfigurationsRequest) returns (GetAllConfigurationsResponse){ + option (google.api.http) = { + get: "/Configuration/GetAll" + }; + }; + rpc GetConfigurationHistory(GetConfigurationHistoryRequest) returns (GetConfigurationHistoryResponse){ + option (google.api.http) = { + get: "/Configuration/GetHistory" + }; + }; +} + +// CreateOrUpdate Command +message CreateOrUpdateConfigurationRequest +{ + string key = 1; + string value = 2; + google.protobuf.StringValue description = 3; + int32 scope = 4; // ConfigurationScope enum: System=0, Network=1, Club=2, Commission=3 +} + +// Deactivate Command +message DeactivateConfigurationRequest +{ + string key = 1; + google.protobuf.StringValue reason = 2; +} + +// GetByKey Query +message GetConfigurationByKeyRequest +{ + string key = 1; +} + +message GetConfigurationByKeyResponse +{ + int64 id = 1; + string key = 2; + string value = 3; + string description = 4; + int32 scope = 5; + bool is_active = 6; + google.protobuf.Timestamp created = 7; + google.protobuf.Timestamp last_modified = 8; +} + +// GetAll Query +message GetAllConfigurationsRequest +{ + google.protobuf.Int32Value scope = 1; + google.protobuf.BoolValue is_active = 2; + int32 page_index = 3; + int32 page_size = 4; +} + +message GetAllConfigurationsResponse +{ + messages.MetaData meta_data = 1; + repeated ConfigurationModel models = 2; +} + +message ConfigurationModel +{ + int64 id = 1; + string key = 2; + string value = 3; + string description = 4; + int32 scope = 5; + bool is_active = 6; + google.protobuf.Timestamp created = 7; +} + +// GetHistory Query +message GetConfigurationHistoryRequest +{ + google.protobuf.Int64Value configuration_id = 1; + google.protobuf.StringValue key = 2; + int32 page_index = 3; + int32 page_size = 4; +} + +message GetConfigurationHistoryResponse +{ + messages.MetaData meta_data = 1; + repeated ConfigurationHistoryModel models = 2; +} + +message ConfigurationHistoryModel +{ + int64 id = 1; + int64 configuration_id = 2; + string key = 3; + string old_value = 4; + string new_value = 5; + string old_description = 6; + string new_description = 7; + int32 old_scope = 8; + int32 new_scope = 9; + string performed_by = 10; + string reason = 11; + google.protobuf.Timestamp created = 12; +} diff --git a/src/CMSMicroservice.Protobuf/Protos/networkmembership.proto b/src/CMSMicroservice.Protobuf/Protos/networkmembership.proto new file mode 100644 index 0000000..88b53a4 --- /dev/null +++ b/src/CMSMicroservice.Protobuf/Protos/networkmembership.proto @@ -0,0 +1,152 @@ +syntax = "proto3"; + +package networkmembership; + +import "public_messages.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "CMSMicroservice.Protobuf.Protos.NetworkMembership"; + +service NetworkMembershipContract +{ + rpc JoinNetwork(JoinNetworkRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/NetworkMembership/Join" + body: "*" + }; + }; + rpc ChangeNetworkParent(ChangeNetworkParentRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/NetworkMembership/ChangeParent" + body: "*" + }; + }; + rpc RemoveFromNetwork(RemoveFromNetworkRequest) returns (google.protobuf.Empty){ + option (google.api.http) = { + post: "/NetworkMembership/Remove" + body: "*" + }; + }; + rpc GetUserNetwork(GetUserNetworkRequest) returns (GetUserNetworkResponse){ + option (google.api.http) = { + get: "/NetworkMembership/GetUserNetwork" + }; + }; + rpc GetNetworkTree(GetNetworkTreeRequest) returns (GetNetworkTreeResponse){ + option (google.api.http) = { + get: "/NetworkMembership/GetNetworkTree" + }; + }; + rpc GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest) returns (GetNetworkMembershipHistoryResponse){ + option (google.api.http) = { + get: "/NetworkMembership/GetHistory" + }; + }; +} + +// JoinNetwork Command +message JoinNetworkRequest +{ + int64 user_id = 1; + int64 parent_id = 2; + int32 leg = 3; // NetworkLeg enum: Left=0, Right=1 + google.protobuf.StringValue referral_code = 4; +} + +// ChangeParent Command +message ChangeNetworkParentRequest +{ + int64 user_id = 1; + int64 new_parent_id = 2; + int32 new_leg = 3; // NetworkLeg enum + string reason = 4; +} + +// Remove Command +message RemoveFromNetworkRequest +{ + int64 user_id = 1; + string reason = 2; +} + +// GetUserNetwork Query +message GetUserNetworkRequest +{ + int64 user_id = 1; +} + +message GetUserNetworkResponse +{ + int64 id = 1; + int64 user_id = 2; + string user_name = 3; + google.protobuf.Int64Value parent_id = 4; + string parent_name = 5; + int32 network_leg = 6; // NetworkLeg enum + google.protobuf.Int64Value left_child_id = 7; + string left_child_name = 8; + google.protobuf.Int64Value right_child_id = 9; + string right_child_name = 10; + int32 network_level = 11; + string referral_code = 12; + google.protobuf.Timestamp joined_at = 13; + google.protobuf.Timestamp created = 14; +} + +// GetNetworkTree Query +message GetNetworkTreeRequest +{ + int64 root_user_id = 1; + google.protobuf.Int32Value max_depth = 2; + google.protobuf.BoolValue only_active = 3; +} + +message GetNetworkTreeResponse +{ + repeated NetworkTreeNodeModel nodes = 1; +} + +message NetworkTreeNodeModel +{ + int64 user_id = 1; + string user_name = 2; + google.protobuf.Int64Value parent_id = 3; + int32 network_leg = 4; + int32 network_level = 5; + bool is_active = 6; + google.protobuf.Timestamp joined_at = 7; +} + +// GetHistory Query +message GetNetworkMembershipHistoryRequest +{ + google.protobuf.Int64Value user_id = 1; + google.protobuf.Int64Value parent_id = 2; + int32 page_index = 3; + int32 page_size = 4; +} + +message GetNetworkMembershipHistoryResponse +{ + messages.MetaData meta_data = 1; + repeated NetworkMembershipHistoryModel models = 2; +} + +message NetworkMembershipHistoryModel +{ + int64 id = 1; + int64 user_id = 2; + google.protobuf.Int64Value old_parent_id = 3; + google.protobuf.Int64Value new_parent_id = 4; + google.protobuf.Int32Value old_network_leg = 5; + google.protobuf.Int32Value new_network_leg = 6; + google.protobuf.Int32Value old_network_level = 7; + google.protobuf.Int32Value new_network_level = 8; + int32 action = 9; // NetworkMembershipAction enum + string performed_by = 10; + string reason = 11; + google.protobuf.Timestamp created = 12; +} diff --git a/src/CMSMicroservice.WebApi/Services/ClubMembershipService.cs b/src/CMSMicroservice.WebApi/Services/ClubMembershipService.cs new file mode 100644 index 0000000..041bf8b --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/ClubMembershipService.cs @@ -0,0 +1,50 @@ +using CMSMicroservice.Protobuf.Protos.ClubMembership; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.ClubMembershipCQ.Commands.ActivateClubMembership; +using CMSMicroservice.Application.ClubMembershipCQ.Commands.DeactivateClubMembership; +using CMSMicroservice.Application.ClubMembershipCQ.Commands.AssignClubFeature; +using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembership; +using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetAllClubMemberships; +using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembershipHistory; + +namespace CMSMicroservice.WebApi.Services; + +public class ClubMembershipService : ClubMembershipContract.ClubMembershipContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public ClubMembershipService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task ActivateClubMembership(ActivateClubMembershipRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task DeactivateClubMembership(DeactivateClubMembershipRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task AssignFeatureToMembership(AssignFeatureToMembershipRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetClubMembership(GetClubMembershipRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetAllClubMemberships(GetAllClubMembershipsRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetClubMembershipHistory(GetClubMembershipHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/CommissionService.cs b/src/CMSMicroservice.WebApi/Services/CommissionService.cs new file mode 100644 index 0000000..b457927 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/CommissionService.cs @@ -0,0 +1,70 @@ +using CMSMicroservice.Protobuf.Protos.Commission; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.CommissionCQ.Commands.CalculateWeeklyBalances; +using CMSMicroservice.Application.CommissionCQ.Commands.CalculateWeeklyCommissionPool; +using CMSMicroservice.Application.CommissionCQ.Commands.ProcessUserPayouts; +using CMSMicroservice.Application.CommissionCQ.Commands.RequestWithdrawal; +using CMSMicroservice.Application.CommissionCQ.Commands.ProcessWithdrawal; +using CMSMicroservice.Application.CommissionCQ.Queries.GetWeeklyCommissionPool; +using CMSMicroservice.Application.CommissionCQ.Queries.GetUserCommissionPayouts; +using CMSMicroservice.Application.CommissionCQ.Queries.GetCommissionPayoutHistory; +using CMSMicroservice.Application.CommissionCQ.Queries.GetUserWeeklyBalances; + +namespace CMSMicroservice.WebApi.Services; + +public class CommissionService : CommissionContract.CommissionContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public CommissionService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + // Commands + public override async Task CalculateWeeklyBalances(CalculateWeeklyBalancesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task ProcessUserPayouts(ProcessUserPayoutsRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task RequestWithdrawal(RequestWithdrawalRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task ProcessWithdrawal(ProcessWithdrawalRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + // Queries + public override async Task GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetUserCommissionPayouts(GetUserCommissionPayoutsRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetUserWeeklyBalances(GetUserWeeklyBalancesRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs b/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs new file mode 100644 index 0000000..146848a --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/ConfigurationService.cs @@ -0,0 +1,44 @@ +using CMSMicroservice.Protobuf.Protos.Configuration; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue; +using CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration; +using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey; +using CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations; +using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory; + +namespace CMSMicroservice.WebApi.Services; + +public class ConfigurationService : ConfigurationContract.ConfigurationContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public ConfigurationService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task DeactivateConfiguration(DeactivateConfigurationRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetConfigurationByKey(GetConfigurationByKeyRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetAllConfigurations(GetAllConfigurationsRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetConfigurationHistory(GetConfigurationHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +} diff --git a/src/CMSMicroservice.WebApi/Services/NetworkMembershipService.cs b/src/CMSMicroservice.WebApi/Services/NetworkMembershipService.cs new file mode 100644 index 0000000..f8beec5 --- /dev/null +++ b/src/CMSMicroservice.WebApi/Services/NetworkMembershipService.cs @@ -0,0 +1,50 @@ +using CMSMicroservice.Protobuf.Protos.NetworkMembership; +using CMSMicroservice.WebApi.Common.Services; +using CMSMicroservice.Application.NetworkMembershipCQ.Commands.JoinNetwork; +using CMSMicroservice.Application.NetworkMembershipCQ.Commands.MoveInNetwork; +using CMSMicroservice.Application.NetworkMembershipCQ.Commands.RemoveFromNetwork; +using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetUserNetworkPosition; +using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkTree; +using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkMembershipHistory; + +namespace CMSMicroservice.WebApi.Services; + +public class NetworkMembershipService : NetworkMembershipContract.NetworkMembershipContractBase +{ + private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; + + public NetworkMembershipService(IDispatchRequestToCQRS dispatchRequestToCQRS) + { + _dispatchRequestToCQRS = dispatchRequestToCQRS; + } + + public override async Task JoinNetwork(JoinNetworkRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task ChangeNetworkParent(ChangeNetworkParentRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task RemoveFromNetwork(RemoveFromNetworkRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetUserNetwork(GetUserNetworkRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetNetworkTree(GetNetworkTreeRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } + + public override async Task GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest request, ServerCallContext context) + { + return await _dispatchRequestToCQRS.Handle(request, context); + } +}