partial void ToModelPostprocessing(LedgerTransactionDto dto, ref LedgerTransaction model) { // Inheritance could be better handled. var balanaceTransaction = model as BankBalanceAdjustmentTransaction; if (balanaceTransaction != null) { balanaceTransaction.BankAccount = this.accountTypeRepo.GetByKey(dto.Account); } }
public DtoToLedgerTransactionMapperTest() { TestData = new LedgerTransactionDto { Id = TransactionId, Amount = -123.99M, Narrative = "Foo bar.", TransactionType = typeof(CreditLedgerTransaction).FullName }; }
partial void ToDtoPostprocessing(ref LedgerTransactionDto dto, LedgerTransaction model) { dto.TransactionType = model.GetType().FullName; // Inheritance could be better handled. var bankBalanceTransaction = model as BankBalanceAdjustmentTransaction; if (bankBalanceTransaction != null) { dto.Account = bankBalanceTransaction.BankAccount.Name; } }
public void ShouldMapAccountTypeForBalanceAdjustmentTransaction() { TestData = new LedgerTransactionDto { Id = TransactionId, Amount = -123.99M, Narrative = "Foo bar.", Account = StatementModelTestData.ChequeAccount.Name, TransactionType = typeof(BankBalanceAdjustmentTransaction).FullName }; var subject = new Mapper_LedgerTransactionDto_LedgerTransaction(new LedgerTransactionFactory(), new InMemoryAccountTypeRepository()); Result = subject.ToModel(TestData); Assert.AreEqual(StatementModelTestData.ChequeAccount.Name, ((BankBalanceAdjustmentTransaction)Result).BankAccount.Name); }
// ReSharper disable once RedundantAssignment partial void ModelFactory(LedgerTransactionDto dto, ref LedgerTransaction model) { model = this.transactionFactory.Build(dto.TransactionType, dto.Id); }
partial void ToModelPostprocessing(LedgerTransactionDto dto, ref BankBalanceAdjustmentTransaction model) { model.BankAccount = this.accountTypeRepo.GetByKey(dto.Account) ?? this.accountTypeRepo.GetByKey(AccountTypeRepositoryConstants.Cheque); }
partial void ToDtoPostprocessing(ref LedgerTransactionDto dto, BankBalanceAdjustmentTransaction model) { dto.Account = model.BankAccount.Name; dto.TransactionType = model.GetType().FullName; }