Example #1
0
 public AccountsRepository(BankContext context)
 {
     _context        = context;
     _accountsEntity = context.Set <Account>();
 }
Example #2
0
 }                                        // properti koji ce da ukazuje na context, tj preko njega preuzimamo podatke iz baze podataka
 public BankController(BankContext context)
 {
     Context = context;
 }
 public HomeController(BankContext context)
 {
     db = context;
 }
Example #4
0
 public AccountController(BankContext context)
 {
     _context = context;
 }
 public BankGeneric()
 {
     _context = new BankContext();
 }
 // A Constructor for Effort Tests
 public Depositing(BankContext bankContext)
 {
     this.bankContext = bankContext;
 }
 public AccountRepository(BankContext bankContext)
 {
     _bankContext = bankContext;
 }
 public UserRepository(BankContext context)
 {
     _context = context;
 }
Example #9
0
 public BankClientController(BankContext bankContext)
 {
     BankContext = bankContext;
 }
 public OperationsRepo(BankContext context)
 {
     _context = context;
 }
Example #11
0
 public DepositHandler()
 {
     _context = new BankContext();
 }
 public BancoRepository(BankContext contexto) : base(contexto)
 {
 }
 public double CalculateInterest(BankContext context, IAccount account)
 {
     return(account.Balance * 0.035);
 }
 public AcctInfoController(BankContext context)
 {
     _context = context;
 }
 public BankTotalBalanceRepo(BankContext context)
 {
     _context = context;
 }
Example #16
0
 public GetCustomersByNameHandler()
 {
     _context = new BankContext();
 }
 public Depositing()
 {
     bankContext = new BankContext();
     bankContext.Configuration.ProxyCreationEnabled = false;
 }
 public LoginRegController(BankContext context)
 {
     _context = context;
 }
Example #19
0
 public CreditPaymentRepository(BankContext context)
     : base(context)
 {
 }
Example #20
0
 public UnitOfWork(BankContext bankContext)
 {
     this._bankContext = bankContext;
 }
Example #21
0
        internal static decimal AcctBalance(string AcctNum, BankContext ctx)
        {
            var acctBal = ctx.Accounts.Single(acct => acct.AcctNumber == AcctNum);

            return(acctBal.AcctBalance);
        }
Example #22
0
        private static void BankConsole(BankContext ctx)
        {
            Console.WriteLine("Hello, summoner! Welcome to Soft Uni Bank (SUB)");
            Console.WriteLine("-----------------------------------------------");
            Console.WriteLine("Type 'commands' to see the available commands!");
            Console.WriteLine("Type 'Quit' to quit the application!");
            Console.WriteLine("-----------------------------------------------");
            string loggedUsername     = "";
            string loggedUserPassword = "";
            var    command            = Console.ReadLine();

            while (command != "Quit")
            {
                var array = command.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
                if (command == "commands")
                {
                    Console.WriteLine("1. Register <username> <password> <email> - That command add new user to the database in case username, password and email are valid. Otherwise print appropriate message informing why the user cannot be registered");
                    Console.WriteLine("2. Login <username> <password> - - That command set the current logged in user if exists. Otherwise print appropriate message.");
                    Console.WriteLine("3. Logout - log out the user from the system. If there is no logged in user print appropriate message.");
                    Console.WriteLine("4. Add SavingAccount <initial balance> <interest rate> - add saving account to the currently logged in user. ");
                    Console.WriteLine("5. Add CheckingAccount <initial balance> <fee> - add checking account to the currently logged in user. ");
                    Console.WriteLine("6. ListAccounts – prints a list of overall information for all accounts of currently logged in user.");
                    Console.WriteLine("7. Deposit <Account number> <money> - adds money to the account with given number");
                    Console.WriteLine("8. Withdraw <Account number> <money> - subtracts money from the account with given number");
                    Console.WriteLine("9. DeductFee <Account number> - deduct the fee from the balance of the account with given number");
                    Console.WriteLine("10. AddInterest <Account number> - add interest to the balance of the account with given number");
                    Console.WriteLine("---------------------------------------------------------------------------------------------------------------------");
                }
                if (array[0] == "Register")
                {
                    var user = new User();
                    user.Username = array[1];
                    user.Password = array[2];
                    user.Email    = array[3];
                    ctx.Users.Add(user);
                    ctx.SaveChanges();
                    Console.WriteLine($"{user.Username} was registered.");
                }
                if (array[0] == "Login")
                {
                    var username    = array[1];
                    var password    = array[2];
                    var user        = ctx.Users.Where(u => u.Username == username).FirstOrDefault();
                    var listOfUsers = ctx.Users.ToList();
                    if (listOfUsers.Contains(user))
                    {
                        loggedUsername     = user.Username;
                        loggedUserPassword = user.Password;
                        Console.WriteLine("Succesfully logged in!");
                    }
                    else
                    {
                        Console.WriteLine("There is no such user!");
                    }
                }
                if (array[0] == "Logout")
                {
                    if (loggedUsername == string.Empty)
                    {
                        Console.WriteLine("Cannot log out. No user was logged in.");
                    }
                    else
                    {
                        Console.WriteLine($"{loggedUsername} succesfully logged out.");
                        loggedUsername     = "";
                        loggedUserPassword = "";
                    }
                }
                if (array[0] == "Add")
                {
                    if (loggedUsername == "")
                    {
                        Console.WriteLine("Please login first!");
                    }
                    else
                    {
                        if (array[1] == "SavingAccount")
                        {
                            var savingAccount = new SavingAccount();
                            savingAccount.Balance       = decimal.Parse(array[2]);
                            savingAccount.InterestRate  = decimal.Parse(array[3]);
                            savingAccount.AccountNumber = RandomString();
                            ctx.SavingAccounts.Add(savingAccount);
                            ctx.SaveChanges();
                            Console.WriteLine($"Succesfully added saving account with number: {savingAccount.AccountNumber}");
                        }
                        if (array[1] == "CheckingAccount")
                        {
                            var checkingAccount = new CheckingAccount();
                            checkingAccount.Balance       = decimal.Parse(array[2]);
                            checkingAccount.Fee           = decimal.Parse(array[3]);
                            checkingAccount.AccountNumber = RandomString();
                            ctx.CheckingAccounts.Add(checkingAccount);
                            ctx.SaveChanges();
                            Console.WriteLine($"Succesfully added checking account with number: {checkingAccount.AccountNumber}");
                        }
                    }
                }
                if (array[0] == "ListAccounts")
                {
                    var list1 = ctx.SavingAccounts.OrderBy(c => c.AccountNumber).ToList();
                    var list2 = ctx.CheckingAccounts.OrderBy(c => c.AccountNumber).ToList();
                    Console.WriteLine("Saving accounts:");
                    foreach (var sa in list1)
                    {
                        Console.WriteLine($"-- {sa.AccountNumber} {sa.Balance} ");
                    }
                    Console.WriteLine("Checking accounts:");
                    foreach (var ca in list2)
                    {
                        Console.WriteLine($"-- {ca.AccountNumber} {ca.Balance}");
                    }
                }
                if (array[0] == "Deposit" && loggedUsername != "")
                {
                    var accountNumber = array[1];
                    var sum           = decimal.Parse(array[2]);
                    var list1         = ctx.SavingAccounts.ToList();
                    var list2         = ctx.CheckingAccounts.ToList();
                    foreach (var item in list1)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            item.DepositMoney(sum);
                            ctx.SaveChanges();
                            Console.WriteLine($"Succesfully added money to saving account: {item.AccountNumber}");
                            Console.WriteLine($"Balance: {item.Balance}$");
                        }
                    }
                    foreach (var item in list2)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            item.DepositMoney(sum);
                            ctx.SaveChanges();
                            Console.WriteLine($"Succesfully added money to checking account: {item.AccountNumber}");
                            Console.WriteLine($"Balance: {item.Balance}$");
                        }
                    }
                }
                if (array[0] == "Withdraw" && loggedUsername != "")
                {
                    var accountNumber = array[1];
                    var sum           = decimal.Parse(array[2]);
                    var list1         = ctx.SavingAccounts.ToList();
                    var list2         = ctx.CheckingAccounts.ToList();
                    foreach (var item in list1)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            item.WithdrawMoney(sum);
                            ctx.SaveChanges();
                            if (item.Balance > sum)
                            {
                                Console.WriteLine($"Succesfully withdrawed money from saving account: {item.AccountNumber}");
                                Console.WriteLine($"Balance: {item.Balance}$");
                            }
                        }
                    }
                    foreach (var item in list2)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            item.WithdrawMoney(sum);
                            ctx.SaveChanges();
                            if (item.Balance > sum)
                            {
                                Console.WriteLine($"Succesfully withdrawed money from saving account: {item.AccountNumber}");
                                Console.WriteLine($"Balance: {item.Balance}$");
                            }
                        }
                    }
                }

                if (array[0] == "DeductFee" && loggedUsername != "")
                {
                    var accountNumber = array[1];
                    var list          = ctx.CheckingAccounts.ToList();
                    foreach (var item in list)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            var fee = decimal.Parse(array[2]);
                            item.DeductFee(fee);
                            ctx.SaveChanges();
                            Console.WriteLine("Succesfully added new fee!");
                        }
                    }
                }
                if (array[0] == "AddInterest" && loggedUsername != "")
                {
                    var accountNumber = array[1];
                    var list          = ctx.SavingAccounts.ToList();
                    foreach (var item in list)
                    {
                        if (item.AccountNumber == accountNumber && item.User.Username == loggedUsername)
                        {
                            var interest = decimal.Parse(array[2]);
                            item.AddInterest(interest);
                            ctx.SaveChanges();
                            Console.WriteLine("Succesfully added new interest!");
                            Console.WriteLine($"Balance: {item.Balance}$");
                        }
                    }
                }
                command = Console.ReadLine();
            }
            Console.WriteLine("GG WP!");
        }
 public AuthorizationController(BankContext context)
 {
     _context = context;
 }
Example #24
0
 public AccountManager(UserManager <AppUser> userManager, SignInManager <AppUser> signInManager, IJwtGenerator jwtGenerator, BankContext db, ILogger <AccountManager> logger)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _jwtGenerator  = jwtGenerator;
     _db            = db;
     _logger        = logger;
 }
Example #25
0
 public UserController(BankContext context)
 {
     _context = context;
 }
Example #26
0
 public BaseRepository(BankContext context)
 {
     _context = context;
     entities = _context.Set <T>();
 }
Example #27
0
 public RepositoryBase(BankContext contexto)
 {
     this._contexto = contexto;
     this._dbSet    = this._contexto.Set <TEntity>();
 }
Example #28
0
 public TermsController(BankContext context)
 {
     _context = context;
 }
Example #29
0
 public CustomersController(BankContext context)
 {
     _context = context;
 }
Example #30
0
 public BankRepository()
 {
     this.db = new BankContext();
 }