Example #1
0
        // <summary>
        //  first checks for a match between the given email&password and the the user list on 'dataset'
        //  then, if succesful, goes through the boards data-set on 'BoardsManager' and looks-up
        //  the matching board.
        //  *note - the fuction 'init' must be called succesfully before calling this fuction.
        // </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        // <returns>
        //  if succesful,this function returns a User type object that represents ,and acts as, the current
        //  active user. otherwise it returns 'null'.
        // </returns>
        public User login(String email, String password)
        {
            bool isMatch     = false;
            User currentUser = null;

            try
            {
                if (dataset[email].getPassword().Equals(password))
                {
                    isMatch = true;
                }
            }
            catch (NullReferenceException)
            {
                log.Error("Attempted login before data was retrieved");
            }
            catch (KeyNotFoundException)
            {
                log.Info("Failed login attempt: email [" + email + "] is not registered or password input does not match");
            }

            if (boards != null && isMatch)
            {
                BoardsCollection tempBoard = boards.getBoardCollection(email);
                currentUser = new User(email, password, tempBoard);
            }
            else if (boards == null)
            {
                log.Error("Attempted login system has been initialized");
            }
            return(currentUser);
        }
Example #2
0
        //---------------------------------additional methods-------------------------------//
        public BoardsCollection getBoardCollection(String email)
        {
            List <Board> myboards = dataset.FindAll(brd => email.Equals(brd.getID()));

            if (myboards.Count == 0)
            {
                Board curr = new Board(email, "Main Board");
                dataset.Add(curr);
                myboards.Add(curr);
                saveBoard(email, "Main Board");
            }
            BoardsCollection boardscoll = new BoardsCollection(email, myboards);

            return(boardscoll);
        }
Example #3
0
 public BoardInter(BoardsCollection myboards)
 {
     this.myboards = myboards;
     currBoard     = myboards.getBoardAt(0); //assuming the boards manager makes sure
                                             //there is at least 1 board in collection
 }