public bool CreditCustomerAccount(decimal amount, int id, CustomerAccount account)
        {
            if (account.AccountType == AccountType.Savings || account.AccountType == AccountType.Current)
            {
                if (id != 0)
                {
                    ApplicationDbContext _context        = new ApplicationDbContext();
                    CustomerAccount      customerAccount = _customer.Get(id);
                    customerAccount.Balance += amount;

                    _context.Entry(customerAccount).State = EntityState.Modified;
                    _context.SaveChanges();
                }
            }
            else
            {
                ApplicationDbContext _context        = new ApplicationDbContext();
                CustomerAccount      customerAccount = _customer.Get(id);
                customerAccount.Balance -= amount;

                _context.Entry(customerAccount).State = EntityState.Modified;
                _context.SaveChanges();
            }

            //Logging values
            _transaction.LogCustomer(account, amount, TransactionType.Credit);
            return(true);
        }
Exemplo n.º 2
0
        public Customer Get(Guid id)
        {
            var customer         = _appDbContext.Customer.FirstOrDefault(s => s.Id == id);
            var customerAccounts = _customerAccountRepository.Get(customer.Id);

            foreach (var account in customerAccounts)
            {
                customer.Accounts.Add(_accountRepository.Get(account.AccountId));
            }

            return(customer);
        }
Exemplo n.º 3
0
        public void RemoveOneOffItem(OneOffItem oneOffItem)
        {
            var account =
                _customerAccountRepository.Get(c => c.OneOffItems.Any(o => o.OneOffItemId == oneOffItem.OneOffItemId));

            if (oneOffItem.Refunded)
            {
                _accountTransactionService.AddAccountTransaction(account.CustomerAccountId, AccountTransactionType.Refund,
                                                                 -oneOffItem.TotalCharge, AccountTransactionInputType.Charge, 0, "One Off :" + oneOffItem.Description);
            }
            oneOffItem.RemovalDate = DateTime.Today;

            _customerAccountRepository.Update(account);
        }