public IActionResult GetSecondaryCheckingTransactionHistory(DateTime?fromDt, DateTime?toDt) { try { if (BankAccountValidation.VerifyInputFromDate(_logger, fromDt.Value) == false) { return(BadRequest("The To Date input value is not valid")); } toDt = BankAccountValidation.VerifyInputToDate(_logger, toDt.Value); //note: wrapping the uow into a using block to approximate true data access against a DB, per best practices using (IUnitOfWork uow = new UnitOfWork()) { var acctFactory = new AccountFactory(); var secondaryChecking = acctFactory.CreateInstance(AccountTypeEnum.SecondaryChecking); IAccountManager acctMgr = new AccountManager(secondaryChecking, uow); var ledger = acctMgr.ViewLedgerByDateRange(fromDt.Value, toDt.Value); var results = Mapper.Map <IEnumerable <TransactionDTO> >(ledger); return(Ok(results)); } } catch (Exception ex) { _logger.LogCritical($"Exception thrown in the AccountController. Message details: {ex.Message}"); return(StatusCode(500, "An error was detected in the Account Controller. View message log for details.")); } }
public IActionResult CreatePrimaryCheckingDeposit([FromBody] TransactionDTO transaction) { try { if (BankAccountValidation.VerifyInputForDeposit(_logger, transaction) == false) { return(BadRequest("The deposit type is not known")); } //note: wrapping the uow into a using block to approximate true data access against a DB, per best practices using (IUnitOfWork uow = new UnitOfWork()) { var acctFactory = new AccountFactory(); var primaryChecking = acctFactory.CreateInstance(AccountTypeEnum.PrimaryChecking); IAccountManager acctMgr = new AccountManager(primaryChecking, uow); var transactionEntity = Mapper.Map <Transaction>(transaction); acctMgr.RecordDepositOrWithdrawal(transactionEntity); return(StatusCode(201)); } } catch (Exception ex) { _logger.LogCritical($"Exception thrown in the AccountController. Message details: {ex.Message}"); return(StatusCode(500, "An error was detected in the Account Controller. View message log for details.")); } }