Beispiel #1
0
        public List <AccountDetailDTO> GetUserAccounts([FromBody] String userId)
        {
            AccountDetailDTO        accountDetail;
            List <AccountDetailDTO> accountDetailList = new List <AccountDetailDTO>();

            List <BankAccount> accountsList = _accountDBAccess.FindByUser(userId);

            foreach (BankAccount account in accountsList)
            {
                List <Transaction> accountTransactions = _transactionDBAccess.FindByAccount(account.BankAccountId);

                decimal balance = _businessService.GetAccountBalance(accountTransactions, account.InitialAmount);
                accountDetail = new AccountDetailDTO
                {
                    AccountId           = account.BankAccountId,
                    Name                = account.Name,
                    InitialAmount       = account.InitialAmount,
                    Balance             = balance,
                    LastTransactionDate = accountTransactions.Count != 0 ? DateConverter.DateTimeToLong(accountTransactions.Last().TransactionDate) : 0,
                    UserId              = account.UserId
                };
                accountDetailList.Add(accountDetail);
            }
            return(accountDetailList);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Non-Adapted:");
            var nonAdaptedPerson = new AccountDTO(CustomerType.Person);

            nonAdaptedPerson.Display();

            Console.WriteLine("\n\nAdapted:");
            var person = new AccountDetailDTO(CustomerType.Person);

            person.Display();
            var company = new AccountDetailDTO(CustomerType.Company);

            company.Display();
            var staff = new AccountDetailDTO(CustomerType.Staff);

            staff.Display();
        }
Beispiel #3
0
        public static List <AccountDetailDTO> GetEmployeeByMonth(int month, int year, bool salaried = false)
        {
            List <AccountDetailDTO> List = new List <AccountDetailDTO>();
            string query = string.Format("SELECT * FROM EMPLOYEEHISTORY e " +
                                         "RIGHT JOIN ACCOUNT a ON a.ID = e.ACCOUNTID AND e.MONTH = {0} AND e.YEAR = {1} WHERE e.ACCOUNTID IS NULL", month, year);

            if (salaried)
            {
                query = string.Format("SELECT * FROM EMPLOYEEHISTORY e " +
                                      "RIGHT JOIN ACCOUNT a ON a.ID = e.ACCOUNTID AND e.MONTH = {0} AND e.YEAR = {1} WHERE e.ACCOUNTID IS NOT NULL", month, year);
            }

            DataTable data = DataProvider.Instance.ExcuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                AccountDetailDTO account = new AccountDetailDTO(item);
                List.Add(account);
            }
            return(List);
        }