public AccountTransactionViewModel(IBankAppDataContext context)
 {
     Deposit    = false;
     Withdrawal = false;
     Transfer   = false;
     _context   = context;
 }
Exemplo n.º 2
0
        public bool AreDifferentAccounts(int accountFrom, int accountTo, IBankAppDataContext context)
        {
            Account from = context.Accounts.Where(a => a.AccountId == accountFrom).SingleOrDefault();
            Account to   = context.Accounts.Where(a => a.AccountId == accountTo).SingleOrDefault();

            if (from != null && to != null)
            {
                if (from.AccountId != to.AccountId)
                {
                    return(true);
                }
                else if (from.AccountId == to.AccountId)
                {
                    ErrorMessage += "; Accounts are the same";
                    return(false);
                }
                return(false);
            }
            else if (from == null)
            {
                ErrorMessage += "; Account '" + accountFrom + "' doesn't exsist";
                return(false);
            }
            else if (to == null)
            {
                ErrorMessage += "; Account '" + accountTo + "' doesn't exsist";
                return(false);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public void Withdrawal(int accountId, decimal amount, IBankAppDataContext context)
        {
            Account account = context.Accounts.Where(a => a.AccountId == accountId).SingleOrDefault();

            if (IsWidthdrawalAllowed(accountId, amount, context))
            {
                account.Balance -= amount;
                context.Save();
            }
        }
Exemplo n.º 4
0
        public bool MakeDeposit(IBankAppDataContext context)
        {
            CreateTransaction createTransaction = new CreateTransaction(context);

            if (createTransaction.Deposit(Account, Amount))
            {
                StatusMessage = "Deposit successful";
                return(true);
            }
            StatusMessage = createTransaction.ErrorMessage;
            return(false);
        }
Exemplo n.º 5
0
        public bool MakeTransfer(IBankAppDataContext context)
        {
            CreateTransaction createTransaction = new CreateTransaction(context);

            if (createTransaction.Transfer(FromAccount, ToAccount, Amount))
            {
                StatusMessage = "Transfer successful";
                return(true);
            }
            StatusMessage = createTransaction.ErrorMessage;
            return(false);
        }
Exemplo n.º 6
0
        //private IBankAppDataContext _context { get; set; }

        //public CreateCustomer(IBankAppDataContext context)
        //{
        //    _context = context;
        //}

        public int Add(IBankAppDataContext _context, CustomerViewModel model)
        {
            Customer customer = new Customer();

            if (model.IsValid())
            {
                customer.Birthday             = model.Birthday;
                customer.City                 = model.City;
                customer.Country              = model.Country;
                customer.CountryCode          = model.CountryCode;
                customer.Emailaddress         = model.Emailaddress;
                customer.Gender               = model.Gender;
                customer.Givenname            = model.Givenname;
                customer.Surname              = model.Surname;
                customer.Telephonecountrycode = model.Telephonecountrycode;
                customer.Telephonenumber      = model.Telephonenumber;
                customer.Zipcode              = model.Zipcode;
                customer.NationalId           = model.NationalId;
                customer.Streetaddress        = model.Streetaddress;

                _context.Customers.Add(customer);
                _context.Save();

                Account account = new Account()
                {
                    Balance   = 0,
                    Created   = DateTime.Now,
                    Frequency = "Monthly"
                };
                _context.Accounts.Add(account);
                _context.Save();

                Disposition disposition = new Disposition()
                {
                    Account  = account,
                    Customer = customer,
                    Type     = "Owner"
                };
                _context.Dispositions.Add(disposition);
                _context.Save();
            }
            return(customer.CustomerId);
        }
Exemplo n.º 7
0
        public bool Deposit(int accountId, decimal amount, IBankAppDataContext context)
        {
            Account account = context.Accounts.Where(a => a.AccountId == accountId).SingleOrDefault();

            if (account != null)
            {
                if (amount < 0)
                {
                    ErrorMessage = CreditAmountIsLessThanZeroMessage;
                    return(false);
                }
                else if (amount > 0)
                {
                    account.Balance += amount;
                    context.Save();
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        /*----------------------*/


        public bool IsWidthdrawalAllowed(int accountId, decimal amount, IBankAppDataContext context)
        {
            Account account = context.Accounts.Where(a => a.AccountId == accountId).SingleOrDefault();

            if (account != null)
            {
                if (amount > account.Balance)
                {
                    ErrorMessage = DebitAmountExceedsBalanceMessage;
                    return(false);
                }
                else if (amount < 0)
                {
                    ErrorMessage = DebitAmountIsLessThanZeroMessage;
                    return(false);
                }
                return(true);
            }
            else
            {
                ErrorMessage += "; Account ' doesn't exist";
                return(false);
            }
        }
Exemplo n.º 9
0
 public AdminController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IBankAppDataContext context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _context       = context;
 }
Exemplo n.º 10
0
 public GetAccountsQuery(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
 public HomeController(IBankAppDataContext context)
 {
     _context = context;
 }
 public GetTransactionHistoryQueryHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
 public LoginController(IConfiguration config, IBankAppDataContext context)
 {
     _config  = config;
     _context = context;
 }
 public AccountController(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 15
0
 public CreateCustomerCommandHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 16
0
 public GetCustomers(IBankAppDataContext context)
 {
     _context = context;
 }
 public CreateTransactionCommandHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 18
0
 public GetCustomersListQueryHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 19
0
        /*
         * DbSet<Account> IBankAppDataContext.Accounts { get; set; }
         * DbSet<Card> IBankAppDataContext.Cards { get; set; }
         * DbSet<Customer> IBankAppDataContext.Customers { get; set; }
         * DbSet<Disposition> IBankAppDataContext.Dispositions { get; set; }
         * DbSet<Loan> IBankAppDataContext.Loans { get; set; }
         * DbSet<PermenentOrder> IBankAppDataContext.PermenentOrder { get; set; }
         * DbSet<Transaction> IBankAppDataContext.Transactions { get; set; }
         */

        public GetNumberOfCustomersQuery(IBankAppDataContext iBankAppDataContext)
        {
            _IBankAppDataContext = iBankAppDataContext;
        }
 public CustomerController(IBankAppDataContext context)
 {
     _context = context;
 }
 public GetBankStatisticsQueryHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 22
0
 public EditCustomer(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 23
0
 public CustomerDetailsQueryHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 24
0
 public GetTransactions(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 25
0
 public CreateTransaction(IBankAppDataContext context)
 {
     _context       = context;
     accountHandler = new AccountHandler();
 }
Exemplo n.º 26
0
 public GetCustomerInfoQuery(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 27
0
 public GetBankInfoQueryHandler(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 28
0
 public GetNumberOfAccountsQuery(IBankAppDataContext iBankAppDataContext)
 {
     _IBankAppDataContext = iBankAppDataContext;
 }
Exemplo n.º 29
0
 public CustomerInfo(IBankAppDataContext context)
 {
     _context = context;
 }
Exemplo n.º 30
0
        }                                                 //= new BankAppDataContext();

        public HomeIndex(IBankAppDataContext context)
        {
            _context = context;
        }