Exemplo 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");
            }
        }
Exemplo n.º 2
0
        // Create transaction
        public int create(int orderID, int custID, int bankID)
        {
            // Establishes transaction model
            TransactionModel transModel = new TransactionModel();

            // Holds the new transaction
            Transaction newTrans = new Transaction();

            // Stored details for the transaction
            newTrans.DateOfOrder = DateTime.Now;
            newTrans.OrderID = orderID;
            newTrans.CustomerID = custID;
            newTrans.BankID = bankID;

            // Adds object to the database
            int transactionID = transModel.CreateTransaction(newTrans);

            // Returns the transactionID
            return transactionID;
        }