Beispiel #1
0
        //-> SelectByID
        public async Task <AccountViewDTO> SelectByID(int id)
        {
            var account = await db.tblAccounts.FirstOrDefaultAsync(a => a.acct_Deleted == null && a.acct_AccountID == id);

            if (account == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "NotFound");
            }

            var accountView = DoubleHelper.TwoPrecision(MappingHelper.MapDBClassToDTO <tblAccount, AccountViewDTO>(account));

            accountView.statusCaption = SelectionHelper.AccountStatusCaption(account.acct_Status);
            accountView.documents     = DocumentHelper.GetDocuments(db, ConstantHelper.TABLE_ACCOUNT_ID, account.acct_AccountID);
            return(accountView);
        }
        //-> SelectByID
        public async Task <CheckLoanRequestViewDTO> SelectByID(int id)
        {
            var accountHandler   = new AccountHandler();
            var checkLoanRequest = new CheckLoanRequestViewDTO();

            checkLoanRequest.account = DoubleHelper.TwoPrecision(await accountHandler.SelectByID(id));

            var loanRequest = await db.tblLoanRequests.FirstOrDefaultAsync(l =>
                                                                           (l.loan_Status.ToLower() != "approved" && l.loan_Status.ToLower() != "rejected") &&
                                                                           l.loan_Deleted == null && l.loan_AccountID == id);

            if (loanRequest == null)
            {
                loanRequest = new tblLoanRequest();
            }

            checkLoanRequest.loanRequest = DoubleHelper.TwoPrecision(MappingHelper.MapDBClassToDTO <tblLoanRequest, LoanRequestViewDTO>(loanRequest));
            //checkLoanRequest.loanRequest = MappingHelper.MapDBClassToDTO<tblLoanRequest, LoanRequestViewDTO>(loanRequest);
            return(DoubleHelper.TwoPrecision(checkLoanRequest));
        }