Example #1
0
        public static TransactionDetailsOutDto EntityToOutDto(TransactionEntity transactionEntity)
        {
            TransactionDetailsOutDto createdTransactionDetails = transactionEntity switch
            {
                CreditTransactionEntity creditTransactionEntity => new CreditTransactionDetailsOutDto()
                {
                    CreditorName    = creditTransactionEntity.CreditorName,
                    CreditorAccount =
                        AccountReferenceOutDto.EntityToOutDto <AccountReferenceOutDto>(creditTransactionEntity
                                                                                       .CreditorAccount),
                    ValueDate       = creditTransactionEntity.ValueDate,
                    TransactionType = TransactionTypeEnum.CREDIT
                },
                DebitTransactionEntity debitTransactionEntity => new DebitTransactionDetailsOutDto()
                {
                    DebtorName    = debitTransactionEntity.DebtorName,
                    DebtorAccount =
                        AccountReferenceOutDto.EntityToOutDto <AccountReferenceOutDto>(debitTransactionEntity
                                                                                       .DebtorAccount),
                    TransactionType = TransactionTypeEnum.DEBIT
                },
                _ => throw new ArgumentOutOfRangeException(nameof(transactionEntity))
            };

            createdTransactionDetails.TransactionId     = transactionEntity.TransactionId;
            createdTransactionDetails.CheckId           = transactionEntity.CheckId;
            createdTransactionDetails.BookingDate       = transactionEntity.BookingDate;
            createdTransactionDetails.TransactionAmount = AmountOutDto.EntityToOutDto(transactionEntity.TransactionAmount);
            createdTransactionDetails.BookingStatus     = transactionEntity.BookingStatus;
            createdTransactionDetails.EntryDate         = transactionEntity.EntryDate;

            return(createdTransactionDetails);
        }
    }
Example #2
0
 public static AccountTransactionsListOutDto BuildFromEntities(AccountDetailEntity accountDetailEntity,
                                                               ICollection <TransactionEntity> transactionEntities)
 {
     return(new AccountTransactionsListOutDto()
     {
         Account = AccountReferenceOutDto.EntityToOutDto <AccountReferenceOutDto>(accountDetailEntity),
         Transactions = new TransactionListsOutDto()
         {
             Booked = transactionEntities.Where(t => t.BookingStatus == BookingStatusEnum.BOOKED)
                      .Select(TransactionDetailsOutDto.EntityToOutDto),
             Pending = transactionEntities.Where(t => t.BookingStatus == BookingStatusEnum.PENDING)
                       .Select(TransactionDetailsOutDto.EntityToOutDto)
         }
     });
 }