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
140 changes: 140 additions & 0 deletions TransactionMobile.Maui.BusinessLogic/Models/ContractProductModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
namespace TransactionMobile.Maui.BusinessLogic.Models
{
public class ContractOperatorModel
{
#region Properties

/// <summary>
/// Gets or sets the operator identifier.
/// </summary>
/// <value>
/// The operator identifier.
/// </value>
public Guid OperatorId { get; set; }

/// <summary>
/// Gets or sets the operator identfier.
/// </summary>
/// <value>
/// The operator identfier.
/// </value>
public String OperatorIdentfier { get; set; }

/// <summary>
/// Gets or sets the name of the operator.
/// </summary>
/// <value>
/// The name of the operator.
/// </value>
public String OperatorName { get; set; }

#endregion
}

public class ContractProductModel
{
#region Properties

/// <summary>
/// Gets or sets the contract identifier.
/// </summary>
/// <value>
/// The contract identifier.
/// </value>
public Guid ContractId { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this instance is fixed value.
/// </summary>
/// <value>
/// <c>true</c> if this instance is fixed value; otherwise, <c>false</c>.
/// </value>
public Boolean IsFixedValue { get; set; }

/// <summary>
/// Gets or sets the operator identifier.
/// </summary>
/// <value>
/// The operator identifier.
/// </value>
public Guid OperatorId { get; set; }

/// <summary>
/// Gets or sets the operator identfier.
/// </summary>
/// <value>
/// The operator identfier.
/// </value>
public String OperatorIdentfier { get; set; }

/// <summary>
/// Gets or sets the name of the operator.
/// </summary>
/// <value>
/// The name of the operator.
/// </value>
public String OperatorName { get; set; }

/// <summary>
/// Gets or sets the product display text.
/// </summary>
/// <value>
/// The product display text.
/// </value>
public String ProductDisplayText { get; set; }

/// <summary>
/// Gets or sets the product identifier.
/// </summary>
/// <value>
/// The product identifier.
/// </value>
public Guid ProductId { get; set; }

/// <summary>
/// Gets or sets the type of the product.
/// </summary>
/// <value>
/// The type of the product.
/// </value>
public ProductType ProductType { get; set; }

/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>
/// The value.
/// </value>
public Decimal Value { get; set; }

#endregion
}

public enum ProductType
{
/// <summary>
/// The not set
/// </summary>
NotSet = 0,

/// <summary>
/// The mobile topup
/// </summary>
MobileTopup,

/// <summary>
/// The mobile wallet
/// </summary>
MobileWallet,

/// <summary>
/// The bill payment
/// </summary>
BillPayment,

/// <summary>
/// The voucher
/// </summary>
Voucher
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace TransactionMobile.Maui.BusinessLogic.Models;

public class PerformLogonRequestModel
{
#region Properties

public String ApplicationVersion { get; set; }

public String DeviceIdentifier { get; set; }

public DateTime TransactionDateTime { get; set; }

public String TransactionNumber { get; set; }

#endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace TransactionMobile.Maui.BusinessLogic.Models
{
public class PerformMobileTopupRequestModel
{
// TODO: should we have a base transaction request model ?

#region Properties

public String ApplicationVersion { get; set; }

public Guid ContractId { get; set; }

public String CustomerAccountNumber { get; set; }

public String CustomerEmailAddress { get; set; }

public String DeviceIdentifier { get; set; }

public String OperatorIdentifier { get; set; }

public Guid ProductId { get; set; }

public Decimal TopupAmount { get; set; }

public DateTime TransactionDateTime { get; set; }

public String TransactionNumber { get; set; }

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
public class LoginRequestHandler : IRequestHandler<LoginRequest, String>
{
#region Constructors

public LoginRequestHandler(IAuthenticationService authenticationService)
{

this.AuthenticationService = authenticationService;
}

Expand All @@ -32,5 +32,7 @@ public async Task<String> Handle(LoginRequest request,
}

#endregion


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers;

using MediatR;
using Models;
using Requests;
using Services;

public class MerchantRequestHandler : IRequestHandler<GetContractProductsRequest, List<ContractProductModel>>, IRequestHandler<GetMerchantBalanceRequest, Decimal>
{
#region Fields

private readonly IMerchantService MerchantService;

#endregion

#region Constructors
public MerchantRequestHandler(IMerchantService merchantService)
{
this.MerchantService = merchantService;
}

#endregion

#region Methods

public async Task<List<ContractProductModel>> Handle(GetContractProductsRequest request,
CancellationToken cancellationToken)
{
return await this.MerchantService.GetContractProducts(request.AccessToken, request.EstateId, request.MerchantId, cancellationToken);
}

public async Task<Decimal> Handle(GetMerchantBalanceRequest request,
CancellationToken cancellationToken)
{
return await this.MerchantService.GetMerchantBalance(request.AccessToken, request.EstateId, request.MerchantId, cancellationToken);
}

#endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers;

using MediatR;
using Models;
using Requests;
using Services;

public class TransactionRequestHandler : IRequestHandler<PerformMobileTopupRequest, Boolean>, IRequestHandler<LogonTransactionRequest, Boolean>
{
#region Fields

private readonly ITransactionService TransactionService;

#endregion

#region Constructors

public TransactionRequestHandler(ITransactionService transactionService)
{
this.TransactionService = transactionService;
}

#endregion

#region Methods

public async Task<Boolean> Handle(PerformMobileTopupRequest request,
CancellationToken cancellationToken)
{
// TODO: Factory
PerformMobileTopupRequestModel model = new PerformMobileTopupRequestModel
{
ApplicationVersion = request.ApplicationVersion,
ContractId = request.ContractId,
CustomerAccountNumber = request.CustomerAccountNumber,
CustomerEmailAddress = request.CustomerEmailAddress,
DeviceIdentifier = request.DeviceIdentifier,
OperatorIdentifier = request.OperatorIdentifier,
ProductId = request.ProductId,
TopupAmount = request.TopupAmount,
TransactionDateTime = request.TransactionDateTime,
TransactionNumber = request.TransactionNumber
};

Boolean result = await this.TransactionService.PerformMobileTopup(model, cancellationToken);

return result;
}

public async Task<Boolean> Handle(LogonTransactionRequest request,
CancellationToken cancellationToken)
{
// TODO: Factory
PerformLogonRequestModel model = new PerformLogonRequestModel
{
ApplicationVersion = request.ApplicationVersion,
DeviceIdentifier = request.DeviceIdentifier,
TransactionDateTime = request.TransactionDateTime,
TransactionNumber = request.TransactionNumber
};

Boolean result = await this.TransactionService.PerformLogon(model, cancellationToken);

return result;
}

#endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace TransactionMobile.Maui.BusinessLogic.Requests;

using MediatR;
using Models;

public class GetContractProductsRequest : IRequest<List<ContractProductModel>>
{
#region Constructors

private GetContractProductsRequest(String accessToken,
Guid estateId,
Guid merchantId)
{
this.AccessToken = accessToken;
this.EstateId = estateId;
this.MerchantId = merchantId;
}

#endregion

#region Properties

public String AccessToken { get; }

public Guid EstateId { get; }

public Guid MerchantId { get; }

#endregion

#region Methods

public static GetContractProductsRequest Create(String accessToken,
Guid estateId,
Guid merchantId)
{
return new GetContractProductsRequest(accessToken, estateId, merchantId);
}

#endregion
}
Loading