예제 #1
0
        public bool UpdateBoard(int boardId, int groupId, int index, string title,
                                int mode, bool star, String background)
        {
            BoardDAL board = new BoardDAL();

            return(board.UpdateBoard(boardId, groupId, index, title, mode, star, background));
        }
예제 #2
0
        public bool InsertBoard(int index, string title,
                                int mode, bool star, String background)
        {
            BoardDAL board = new BoardDAL();
            int      _star = star ? 1 : 0;

            return(board.InsertBoard(index, title, mode, _star, background));
        }
예제 #3
0
        /// <summary>
        /// Description: This method calls method in DAL layer to retrieve all the list of categories for board from database
        /// </summary>
        /// <returns>List of Categories for board</returns>
        public List <CategoryDBO> GetAllBoardCategories()
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            List <CategoryDBO> lCategoryList = lBoardDAL.GetAllBoardCategories();

            return(lCategoryList);
        }
예제 #4
0
        /// <summary>
        /// Description: This method calls method in DAL layer to find and return the list of specific posts required by user
        /// </summary>
        /// <param name="category">category name that a user specified </param>
        /// <param name="searchString">search string that a user specified </param>
        /// <returns>List of posts that are in the same category and contains searchString that user specified.</returns>
        public List <BoardDBO> GetAllBoards(string category, string searchString)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            List <BoardDBO> oBoardList = lBoardDAL.GetAllBoards(category, searchString);

            return(oBoardList);
        }
예제 #5
0
        /// <summary>
        /// Description: This method calls method in DAL layer to find and returns the post with specific id
        /// </summary>
        /// <param name="id">A unique Board Id</param>
        /// <returns>BoardDBO object with the specific id</returns>
        public BoardDBO FindBoardByBoardID(int id)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            BoardDBO oBoard = lBoardDAL.FindBoardByBoardID(id);

            return(oBoard);
        }
예제 #6
0
        /// <summary>
        /// Description: This method calls method in DAL layer to remove the board in database by boardID and return bool value.
        /// </summary>
        /// <param name="iBoardID">A unique BoardIDPK to find the post to be removed </param>
        /// <returns>If the post is successfully removed, return True. Otherwise, false.</returns>
        public bool RemoveBoardByBoardID(int iBoardID)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            bool lResult = lBoardDAL.RemoveBoardByBoardID(iBoardID);

            return(lResult);
        }
예제 #7
0
        /// <summary>
        /// Description: This method calls method in DAL layer to insert data into database and return integer value.
        /// </summary>
        /// <param name="iBoard"> A BoardDBO object with all the information to be inserted into database </param>
        /// <returns>If the parameter iBoard is successfully inserted into database, return Inserted.IDPK. Otherwise, 0</returns>
        public int CreateBoard(BoardDBO lBoardDBO)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            int lResult = lBoardDAL.CreateBoard(lBoardDBO);

            return(lResult);
        }
예제 #8
0
        /// <summary>
        /// Description: This methods calls method in DAL layer to check if the user who resquested to edit a post has the same user id.
        /// </summary>
        /// <param name="iBoardIDPK"> A unique Board ID </param>
        /// <param name="iUserIDPK"> A unique User ID</param>
        /// <returns>If it is the same user, return true. Otherwise, false </returns>
        public bool FindBoolSameUserByUserIDAndBoardID(int iBoardIDPK, int iUserIDPK)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            bool lResult = lBoardDAL.FindBoolSameUserByUserIDAndBoardID(iBoardIDPK, iUserIDPK);

            return(lResult);
        }
예제 #9
0
        /// <summary>
        /// Description: This method calls method in DAL layer to update a post in the database by BoardIDPK and returns bool value.
        /// </summary>
        /// <param name="iBoardDBO">A post to be updated.</param>
        /// <returns>If the post is successfully updated, return True. Otherwise, false</returns>
        public bool UpdateBoardByBoardID(BoardDBO iBoardDBO)
        {
            // Instantiate BoardDAL object
            BoardDAL lBoardDAL = new BoardDAL();

            bool lResult = lBoardDAL.UpdateBoardByBoardID(iBoardDBO);

            return(lResult);
        }
예제 #10
0
        /// <summary>
        /// Description: This method calls method in DAL layer to retrieve all the posts written by specific user by a unique UserID
        /// </summary>
        /// <param name="id">A unique ID for user</param>
        /// <returns>List of posts that the user has written.</returns>
        public List <BoardDBO> GetAllBoardsByUserID(int id)
        {
            // Instantiate DAL object
            BoardDAL lBoardDAL = new BoardDAL();

            List <BoardDBO> lBoardList = lBoardDAL.GetAllBoardsByUserID(id);

            return(lBoardList);
        }
예제 #11
0
        /// <summary>
        /// Inserts a new board to the table
        /// </summary>
        /// <param name="dalObject">Board to insert</param>
        /// <returns>The generated id of the board inserted in the database</returns>
        public override long Insert(DalObject dalObject)
        {
            using (var connection = new SQLiteConnection(_connectionString))
            {
                BoardDAL         board      = (BoardDAL)dalObject;
                long             output     = -1;
                SQLiteCommand    command    = new SQLiteCommand(null, connection);
                SQLiteDataReader dataReader = null;
                try
                {
                    connection.Open();
                    command.CommandText = $"INSERT INTO {boardsTable} ({BoardDAL.userCreatorColumn}) " +
                                          $"VALUES (@creatorIdVal); SELECT {DalController.seqCol} FROM {DalController.SqlSeq} WHERE {DalController.seqName}='{boardsTable}';";

                    SQLiteParameter userIdParam = new SQLiteParameter(@"creatorIdVal", board.CreatorID);


                    command.Parameters.Add(userIdParam);
                    command.Prepare();

                    dataReader = command.ExecuteReader();

                    if (dataReader.Read())
                    {
                        output = (long)dataReader.GetValue(0);
                    }
                }
                catch (Exception e)
                {
                    log.Error($"Failed to insert board to database{board.Id}", e);
                }
                finally
                {
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                    command.Dispose();
                    connection.Close();
                }
                return(output);
            }
        }
예제 #12
0
 public void delete()
 {
     BoardDAL.deleteBoard(this.Id);
 }
예제 #13
0
        public int GetMaxID()
        {
            BoardDAL board = new BoardDAL();

            return(board.GetMaxID());
        }
예제 #14
0
        public Board GetBoard(int id)
        {
            BoardDAL board = new BoardDAL();

            return(board.GetBoard(id));
        }
예제 #15
0
        public List <Board> GetAllBoard()
        {
            BoardDAL board = new BoardDAL();

            return(board.GetAllBoard());
        }
예제 #16
0
 public void SetTotalLimit(int newLimit)
 {
     this.totalLimit = newLimit;
     BoardDAL.UpdateLimit(this.Id, newLimit);
 }
예제 #17
0
        //============================================================
        public bool AddUser(int idUser, int idBoard)
        {
            BoardDAL board = new BoardDAL();

            return(board.AddUser(idUser, idBoard));
        }
예제 #18
0
        /// <summary>
        /// Converts reader to board dal
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>BoardDAL</returns>
        protected override DalObject ConvertReaderToObject(SQLiteDataReader reader)
        {
            BoardDAL board = new BoardDAL((long)reader.GetValue(0), (long)reader.GetValue(1));

            return(board);
        }
예제 #19
0
 public void save()
 {
     BoardDAL.saveBoard(this.toStruct());
 }
예제 #20
0
        public bool DeleteBoard(int id)
        {
            BoardDAL board = new BoardDAL();

            return(board.DeleteBoard(id));
        }
예제 #21
0
 public static Board GetBoard(int boardID)
 {
     return(new Board(BoardDAL.getBoard(boardID)));
 }
예제 #22
0
        public List <Board> GetAllBoard(int idUser)
        {
            BoardDAL board = new BoardDAL();

            return(board.GetAllBoard(idUser));
        }
예제 #23
0
 public Hashtable getBoards(List <int> MyBoards)
 {
     return(BoardDAL.boardsNameId(MyBoards));
 }