Exemplo n.º 1
0
        public ProfileInterface VerifySession(string sessionID)
        {
            /*
             * This method is called with SessionID, which is the cookie under the key
             * SESSION_ID, it will look up the sessions table, find a user with a corresponding value
             * then create a profile interface of that user.
             * TODO: Make profile types more distinguishable somehow?
             */
            this.dbcmd.CommandText = $"SELECT * FROM sessions";
            Console.WriteLine(this.dbcmd.CommandText);
            var session = this.dbcmd.ExecuteReader();
            ProfileInterface returning = null;

            while (session.Read())
            {
                if (session["ID"].ToString() == sessionID)
                {
                    switch (session["role"].ToString())
                    {
                    case "admin":
                        returning = new AdminProfile(session["username"].ToString(), session["name"].ToString());
                        break;

                    case "teller":
                        returning = new TellerProfile(session["username"].ToString(), session["name"].ToString());
                        break;

                    case "customer":
                        returning = new CustomerProfile(session["username"].ToString(), session["name"].ToString());
                        break;
                    }
                }
            }
            session.Close();
            return(returning);
        }
Exemplo n.º 2
0
        public List <AccountInterface> ListAccounts(string username)
        {
            var customer = new CustomerProfile(username);

            return(customer.ListAccounts());
        }