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
8 changes: 4 additions & 4 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
dotnet test "TransactionProcessor.DatabaseTests\TransactionProcessor.DatabaseTests.csproj"

- name: Build Docker Image
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest
#- name: Build Docker Image
# run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest

- name: Run Integration Tests
run: dotnet test "TransactionProcessor.IntegrationTests\TransactionProcessor.IntegrationTests.csproj" --filter Category=PRTest --logger "trx;LogFileName=test-results.trx"
#- name: Run Integration Tests
# run: dotnet test "TransactionProcessor.IntegrationTests\TransactionProcessor.IntegrationTests.csproj" --filter Category=PRTest --logger "trx;LogFileName=test-results.trx"

- uses: actions/upload-artifact@v4.4.0
if: ${{ failure() }}
Expand Down
70 changes: 48 additions & 22 deletions TransactionProcessor.Repository/ModelFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TransactionProcessor.Models.Merchant;
using TransactionProcessor.Database.Entities;
using TransactionProcessor.Models.Merchant;

namespace TransactionProcessor.Repository
{
Expand Down Expand Up @@ -81,41 +82,66 @@ public static MerchantModel ConvertFrom(Guid estateId,
{
MerchantModel merchantModel = ModelFactory.ConvertFrom(estateId, merchant);

if (merchantAddresses != null && merchantAddresses.Any())
merchantModel.Addresses = ConvertFrom(merchantAddresses);
merchantModel.Contacts = ConvertFrom(merchantContacts);
merchantModel.Operators = ConvertFrom(merchantOperators);
merchantModel.Devices = ConvertFrom(merchantDevices);
merchantModel.SecurityUsers = ConvertFrom(merchantSecurityUsers);

return merchantModel;
}

private static List<MerchantSecurityUserModel> ConvertFrom(List<MerchantSecurityUserEntity> merchantSecurityUsers)
{
List<MerchantSecurityUserModel> users = new List<MerchantSecurityUserModel>();
if (merchantSecurityUsers != null && merchantSecurityUsers.Any())
{
merchantModel.Addresses = new List<MerchantAddressModel>();
merchantAddresses.ForEach(ma => merchantModel.Addresses.Add(new MerchantAddressModel(ma.AddressId,
ma.AddressLine1,
ma.AddressLine2,
ma.AddressLine3,
ma.AddressLine4,ma.Town,ma.Region, ma.PostalCode, ma.Country)));
merchantSecurityUsers.ForEach(msu => users.Add(new MerchantSecurityUserModel(msu.SecurityUserId, msu.EmailAddress)));
}

if (merchantContacts != null && merchantContacts.Any())
{
merchantModel.Contacts = new List<MerchantContactModel>();
merchantContacts.ForEach(mc => merchantModel.Contacts.Add(new MerchantContactModel(mc.ContactId, mc.EmailAddress, mc.Name, mc.PhoneNumber)));
return users;
}

private static List<MerchantAddressModel> ConvertFrom(List<MerchantAddressEntity> merchantAddresses) {
List<MerchantAddressModel> addresses = new List<MerchantAddressModel>();
if (merchantAddresses != null && merchantAddresses.Any()) {
merchantAddresses.ForEach(ma => addresses.Add(new MerchantAddressModel(ma.AddressId, ma.AddressLine1, ma.AddressLine2, ma.AddressLine3, ma.AddressLine4, ma.Town, ma.Region, ma.PostalCode, ma.Country)));
}

if (merchantOperators != null && merchantOperators.Any())
return addresses;
}

private static List<Device> ConvertFrom(List<MerchantDeviceEntity> merchantDevices)
{
List<Device> devices = new List<Device> ();
if (merchantDevices != null && merchantDevices.Any())
{
merchantModel.Operators = new List<MerchantOperatorModel>();
merchantOperators.ForEach(mo => merchantModel.Operators.Add(new MerchantOperatorModel(mo.OperatorId, mo.Name, mo.MerchantNumber, mo.TerminalNumber, mo.IsDeleted)));
merchantDevices.ForEach(md => devices.Add(new Device(md.DeviceId, md.DeviceIdentifier)));
}

if (merchantDevices != null && merchantDevices.Any())
return devices;
}

private static List<MerchantOperatorModel> ConvertFrom(List<MerchantOperatorEntity> merchantOperators)
{
List<MerchantOperatorModel> operators = new List<MerchantOperatorModel>();
if (merchantOperators != null && merchantOperators.Any())
{
merchantModel.Devices = new List<Device>();
merchantDevices.ForEach(md => merchantModel.Devices.Add(new Device(md.DeviceId, md.DeviceIdentifier)));
merchantOperators.ForEach(mo => operators.Add(new MerchantOperatorModel(mo.OperatorId, mo.Name, mo.MerchantNumber, mo.TerminalNumber, mo.IsDeleted)));
}

if (merchantSecurityUsers != null && merchantSecurityUsers.Any())
return operators;
}

private static List<MerchantContactModel> ConvertFrom(List<MerchantContactEntity> merchantContacts)
{
List<MerchantContactModel> contacts = new List<MerchantContactModel>();
if (merchantContacts != null && merchantContacts.Any())
{
merchantModel.SecurityUsers = new List<MerchantSecurityUserModel>();
merchantSecurityUsers.ForEach(msu => merchantModel.SecurityUsers.Add(new MerchantSecurityUserModel(msu.SecurityUserId, msu.EmailAddress)));
merchantContacts.ForEach(mc => contacts.Add(new MerchantContactModel(mc.ContactId, mc.EmailAddress, mc.Name, mc.PhoneNumber)));
}

return merchantModel;
return contacts;
}
}
}
Loading