Esempio n. 1
0
        // Gets all transactions
        public ActionResult Transactions()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return(Redirect("/403.html"));
            }

            bool state = (bool)Session["loggedInState"];

            if (state == true)
            {
                // Creates the models
                var transModel = new TransactionModel();
                var orderModel = new OrderModel();
                var custModel  = new CustomerModel();
                var bankModel  = new BankingModel();

                // Gets the complete list
                var tl = transModel.ListTransactions();

                if (tl.Count != 0)
                {
                    // Attaches associated order / customer / bank to transaction
                    foreach (var trans in tl)
                    {
                        // Acquires, and adds the order to transaction
                        Order order = null;
                        if (trans.OrderID != 0)
                        {
                            order = orderModel.SearchOrder(trans.OrderID);
                        }

                        // Acquires, and adds the customer to transaction
                        Customer cust = null;
                        if (trans.CustomerID != 0)
                        {
                            cust = custModel.SearchCustomers(trans.CustomerID);
                        }

                        // Acquires, and adds the bank to transaction
                        Bank bank = null;
                        if (trans.BankID != 0)
                        {
                            bank = bankModel.SearchBank(trans.BankID);
                        }
                    }
                }

                // Returns the list
                return(View(tl));
            }
            else
            {
                // If not logged in
                return(Redirect("/login.html"));
            }
        }
Esempio n. 2
0
 public ActionResult Insert(BankingModel bm)
 {
     using (StreamWriter a = new StreamWriter(_path.MapPath, true))
     {
         a.WriteLine($"{bm.PIN},{bm.Name},{bm.Surname},{bm.LoanAmount}," +
                     $"{bm.InterestPercent},{bm.IsVariable},{Matrix.CalculateInterestRate(bm).ToString("F")},{Matrix.CalculatePrincipal(bm).ToString("F")}");
     }
     return(RedirectToAction("Main"));
 }
Esempio n. 3
0
        private void DeleteAccount(object sender, RoutedEventArgs e)
        {
            string name = SelectedAccountTextBlock.Text;

            name = name.Split("\t")[0];
            Account a = BankingModel.Accounts.Find(x => x.Name.Equals(name));

            BankingModel.DeleteAccount(a);

            UpdateAccountsListView();
        }
Esempio n. 4
0
        // Returns a list of all banks
        public ActionResult view()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return(Redirect("/403.html"));
            }

            // If logged in
            bool state = (bool)Session["loggedInState"];

            if (state == true)
            {
                // Creates models
                var bankModel    = new BankingModel();
                var addressModel = new AddressModel();

                // Gets the complete list
                var bl = bankModel.ListBanking();

                if (bl.Count != 0)
                {
                    // Attaches associated department / role to employee
                    foreach (var bank in bl)
                    {
                        // Acquires, and adds the bank address
                        Address address = null;
                        if (bank.Address_ID != 0)
                        {
                            address = addressModel.SearchAddress(bank.Address_ID);
                        }

                        // Appends object to bank
                        bank.Address = address;
                    }

                    // Returns the list
                    return(View(bl));
                }
                else
                {
                    return(Redirect("/403.html"));
                }
            }
            else
            {
                // If not logged in
                return(Redirect("/login.html"));
            }
        }
Esempio n. 5
0
        private void AddAccount(object sender, RoutedEventArgs e)
        {
            string name = AccountNameTextBox.Text;

            if (name.Equals(""))
            {
                Debug.WriteLine("Please specify an account name!");
            }
            else
            {
                Account a = new Account(name, 0);
                BankingModel.AddAccount(a);
                UpdateAccountsListView();
                Debug.WriteLine("Account added: " + a.Name);
            }
        }
Esempio n. 6
0
        // Creates a bank
        public int create(String sortCode, int accountNumber)
        {
            // Establishes model
            BankingModel bankModel = new BankingModel();

            // Holds the new bank
            Bank newBank = new Bank();

            // Stored details for the bank
            newBank.SortCode      = sortCode;
            newBank.AccountNumber = accountNumber;

            // Creates the bank
            int bankID = bankModel.CreateBank(newBank);

            // Returns created bank
            return(bankID);
        }