Exemplo n.º 1
0
        partial void ToModelPreprocessing(LedgerEntryDto dto, LedgerEntry model)
        {
            // Transactions must be done first otherwise balance will be changed by adding transactions and the balance should be read from the Dto.
            var transactionMapper = new Mapper_LedgerTransactionDto_LedgerTransaction(this.transactionFactory, this.accountTypeRepo);

            foreach (var txn in dto.Transactions)
            {
                model.AddTransactionForPersistenceOnly(transactionMapper.ToModel(txn));
            }
        }
        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);
        }
        } // End ToModel Method

        public virtual LedgerEntryDto ToDto(LedgerEntry model)
        {
            ToDtoPreprocessing(model);
            LedgerEntryDto dto = null;

            DtoFactory(ref dto, model);
            if (dto == null)
            {
                dto = new LedgerEntryDto();
            }
            var balance49 = model.Balance;

            dto.Balance = balance49;
            var mapper11       = new Mapper_LedgerTransactionDto_LedgerTransaction(this.transactionFactory, this.accountTypeRepo);
            var transactions52 = model.Transactions.Select(mapper11.ToDto).ToList();

            dto.Transactions = transactions52;
            ToDtoPostprocessing(ref dto, model);
            return(dto);
        } // End ToDto Method
 partial void ToModelPreprocessing(LedgerEntryDto dto, LedgerEntry model)
 {
     // Transactions must be done first otherwise balance will be changed by adding transactions and the balance should be read from the Dto.
     var transactionMapper = new Mapper_LedgerTransactionDto_LedgerTransaction(this.transactionFactory, this.accountTypeRepo);
     foreach (var txn in dto.Transactions)
     {
         model.AddTransaction(transactionMapper.ToModel(txn));
     }
 }
 public void TestInitialise()
 {
     var subject = new Mapper_LedgerTransactionDto_LedgerTransaction(new LedgerTransactionFactory(), new InMemoryAccountTypeRepository());
     Result = subject.ToModel(TestData);
 }