Example #1
0
        }                                                                        //empty constructor

        public User(string email, string nickname, string password, int boardId) //Constructing a user that is a board creator
        {
            this.email    = email;
            this.nickname = nickname;
            this.password = password;
            this.board    = new Board(email, boardId);
            this.boardId  = boardId;

            //Inserting to database
            DataAccessLayer.dataUserController DUC = new DataAccessLayer.dataUserController();
            DUC.Insert(this.toDalObject());//insert new user to data base table
        }
Example #2
0
        public User(string email, string nickname, string password, Board b) //Constructing a user that is an assigned user
        {
            this.email    = email;
            this.nickname = nickname;
            this.password = password;
            this.board    = b;
            this.boardId  = b.getBoardId();
            b.addAssignedUser(email);

            //Inserting to database
            DataAccessLayer.dataUserController DUC = new DataAccessLayer.dataUserController();
            DUC.Insert(this.toDalObject());//insert new user to data base table
        }
Example #3
0
        public void loadata()
        {
            if (users.Count == 0) //Cant load data before deleting it
            {
                DataAccessLayer.dataBoardController  boardController  = new DataAccessLayer.dataBoardController();
                DataAccessLayer.dataTaskController   taskController   = new DataAccessLayer.dataTaskController();
                DataAccessLayer.dataColumnController columnController = new DataAccessLayer.dataColumnController();
                DataAccessLayer.dataUserController   UserController   = new DataAccessLayer.dataUserController();
                //Loading from database to dal objects
                List <DataAccessLayer.dataBoard>  allBoards  = boardController.SelectAllBoards();
                List <DataAccessLayer.dataTask>   allTasks   = taskController.SelectAllTasks();
                List <DataAccessLayer.dataColumn> allColumns = columnController.SelectAllColumns();
                List <DataAccessLayer.dataUser>   allUsers   = UserController.SelectAllUsers();
                List <Board> boards = new List <Board>();

                foreach (var dataUser in allUsers)
                {
                    Board busBoard = null;
                    foreach (var dataBoard in allBoards)
                    {
                        if (dataUser.email.Equals(dataBoard.emailCreator)) //Only add the board created by the user
                        {
                            Dictionary <int, Column> busColumns = new Dictionary <int, Column>();
                            foreach (var dataColumn in allColumns)
                            {
                                if (dataColumn.boardId == dataBoard.boardId)
                                {
                                    List <Task> busTasks = new List <Task>();
                                    foreach (var dataTask in allTasks)
                                    {
                                        if (dataTask.column == dataColumn.ordinal & dataColumn.boardId == dataTask.boardId) //Only add the tasks that match the correct column
                                        {
                                            busTasks.Add(new Task(dataTask));                                               //adding to task list business task which is the copy of the data task
                                        }
                                    }
                                    Column busColumn = new Column(dataColumn, busTasks);
                                    busColumns.Add(busColumn.getKey(), busColumn);
                                }
                            }
                            busBoard = new Board(dataBoard, busColumns);
                            boards.Add(busBoard);
                        }
                    }
                    User busUser = new User(dataUser, busBoard);
                    users.Add(busUser.getEmail(), busUser);
                }

                foreach (var user in users)
                {
                    if (user.Value.getBoard() == null) //A user that is not a board creator
                    {
                        foreach (var board in boards)
                        {
                            if (board.getBoardId() == user.Value.getBoardId())
                            {
                                user.Value.setBoard(board); //board is not null
                                board.addAssignedUser(user.Value.getEmail());
                            }
                        }
                    }
                }
                bc.loadData(users); //Loading all Boards to BoardController
            }
        }