Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,18 @@ private async Task HandleAddFee()
isAddingFee = true;
feeErrorMessage = null;

try
{
var estateId = Guid.Parse("11111111-1111-1111-1111-111111111111");
var accessToken = "stubbed-token";
try {
var estateId = await this.GetEstateId();

var command = new Commands.AddTransactionFeeForProductToContractCommand(
var command = new ContractCommands.AddTransactionFeeForProductToContractCommand(
CorrelationIdHelper.New(),
accessToken,
estateId,
ContractId,
currentProductId,
feeModel.Description!,
feeModel.FeeValue!.Value
feeModel.FeeValue!.Value,
this.feeModel.CalculationType,
this.feeModel.FeeType
);

var result = await Mediator.Send(command);
Expand All @@ -195,7 +194,13 @@ private async Task HandleAddFee()
{
successMessage = "Transaction fee added successfully";
CloseAddFeeModal();

// Small delay so user sees confirmation (adjust duration as needed)
await Task.Delay(2500);

await LoadContract();

StateHasChanged();
}
else
{
Expand Down
19 changes: 19 additions & 0 deletions EstateManagmentUI.BusinessLogic/Client/ContractMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Task<Result> CreateContract(ContractCommands.CreateContractCommand request,
CancellationToken cancellationToken);
Task<Result> AddProductToContract(ContractCommands.AddProductToContractCommand request,
CancellationToken cancellationToken);
Task<Result> AddTransactionFeeForProductToContract(ContractCommands.AddTransactionFeeForProductToContractCommand request,
CancellationToken cancellationToken);
}

public partial class ApiClient : IApiClient {
Expand Down Expand Up @@ -124,5 +126,22 @@ public async Task<Result> AddProductToContract(ContractCommands.AddProductToCont

return Result.Success();
}

public async Task<Result> AddTransactionFeeForProductToContract(ContractCommands.AddTransactionFeeForProductToContractCommand request,
CancellationToken cancellationToken) {
var token = await this.GetToken(cancellationToken);
if (token.IsFailed)
return ResultHelpers.CreateFailure(token);

var apiRequest = new AddTransactionFeeForProductToContractRequest() { Value = request.Value,
CalculationType = Enum.Parse<CalculationType>(request.CalculationType), Description = request.Description,
FeeType = Enum.Parse<FeeType>(request.FeeType)};

var apiResult = await this.TransactionProcessorClient.AddTransactionFeeForProductToContract(token.Data, request.EstateId, request.ContractId, request.ProductId, apiRequest, cancellationToken);
if (apiResult.IsFailed)
return ResultHelpers.CreateFailure(apiResult);

return Result.Success();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public class ContractRequestHandler : IRequestHandler<ContractQueries.GetContrac
IRequestHandler<ContractQueries.GetContractQuery, Result<ContractModel>>,
IRequestHandler<ContractCommands.CreateContractCommand, Result>,
IRequestHandler<ContractCommands.AddProductToContractCommand, Result>,
IRequestHandler<Commands.AddTransactionFeeForProductToContractCommand, Result>,
IRequestHandler<ContractCommands.AddTransactionFeeForProductToContractCommand, Result>,
IRequestHandler<ContractQueries.GetRecentContractsQuery, Result<List<RecentContractModel>>>,
IRequestHandler<ContractQueries.GetContractsForDropDownQuery, Result<List<ContractDropDownModel>>>
{
Expand Down Expand Up @@ -206,9 +206,9 @@ public async Task<Result> Handle(ContractCommands.AddProductToContractCommand re
return await this.ApiClient.AddProductToContract(request, cancellationToken);
}

public async Task<Result> Handle(Commands.AddTransactionFeeForProductToContractCommand request,
public async Task<Result> Handle(ContractCommands.AddTransactionFeeForProductToContractCommand request,
CancellationToken cancellationToken) {
return Result.Success();
return await this.ApiClient.AddTransactionFeeForProductToContract(request, cancellationToken);
}

public async Task<Result<List<RecentContractModel>>> Handle(ContractQueries.GetRecentContractsQuery request,
Expand Down
2 changes: 1 addition & 1 deletion EstateManagmentUI.BusinessLogic/Requests/Requests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public record CreateOperatorCommand(CorrelationId CorrelationId, Guid EstateId,
public static class ContractCommands {
public record CreateContractCommand(CorrelationId CorrelationId, Guid EstateId, string Description, Guid OperatorId) : IRequest<Result>;
public record AddProductToContractCommand(CorrelationId CorrelationId, Guid EstateId, Guid ContractId, string ProductName, string DisplayText, decimal? Value) : IRequest<Result>;
public record AddTransactionFeeForProductToContractCommand(CorrelationId CorrelationId, Guid EstateId, Guid ContractId, Guid ProductId, string Description, decimal Value, String CalculationType, String FeeType) : IRequest<Result>;
}

public static class Commands
Expand All @@ -106,5 +107,4 @@ public record CreateMerchantUserCommand(CorrelationId CorrelationId, string Acce



public record AddTransactionFeeForProductToContractCommand(CorrelationId CorrelationId, string AccessToken, Guid EstateId, Guid ContractId, Guid ProductId, string Description, decimal Value) : IRequest<Result>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, Cancellation
OperatorCommands.UpdateOperatorCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteUpdateOperator(cmd)),
ContractCommands.CreateContractCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteCreateContract(cmd)),
ContractCommands.AddProductToContractCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteAddProductToContract(cmd)),
Commands.AddTransactionFeeForProductToContractCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteAddTransactionFee(cmd)),
ContractCommands.AddTransactionFeeForProductToContractCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteAddTransactionFee(cmd)),
MerchantCommands.AssignContractToMerchantCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteAssignContractToMerchant(cmd)),
MerchantCommands.RemoveContractFromMerchantCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteRemoveContractFromMerchant(cmd)),
MerchantCommands.AddOperatorToMerchantCommand cmd => Task.FromResult((TResponse)(object)this.ExecuteAddOperatorToMerchant(cmd)),
Expand Down Expand Up @@ -237,7 +237,7 @@ private Result ExecuteAddProductToContract(ContractCommands.AddProductToContract
return Result.Success();
}

private Result ExecuteAddTransactionFee(Commands.AddTransactionFeeForProductToContractCommand cmd)
private Result ExecuteAddTransactionFee(ContractCommands.AddTransactionFeeForProductToContractCommand cmd)
{
var contract = this._testDataStore.GetContract(cmd.EstateId, cmd.ContractId);
if (contract == null)
Expand Down
Loading