/// <summary>
 /// Updates the current boards name and notes,
 /// then updates the list and database
 /// </summary>
 /// <param name="currentBoard"></param>
 /// <param name="currentIndex"></param>
 /// <returns>If updating was successful</returns>
 internal bool UpdateBoard(BoardViewModel currentBoard, int currentIndex)
 {
     currentBoard.BoardName  = BoardName;
     currentBoard.BoardNotes = BoardNotes;
     BoardList[currentIndex] = currentBoard;
     return(DataProvider.UpdateBoard(currentBoard.BoardId, BoardName, BoardNotes));
 }
        /// <summary>
        /// Creates a new board with BoardName and BoardNotes. Adds
        /// it to the database and collection
        /// </summary>
        public void CreateBoard()
        {
            BoardViewModel newBoard = new BoardViewModel
            {
                BoardName  = BoardName,
                BoardNotes = BoardNotes
            };

            // Add board to db and collection
            int newBoardId = DataProvider.AddBoard(BoardName, BoardNotes);

            newBoard.BoardId = newBoardId.ToString();
            newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
            BoardList.Add(newBoard);
        }
        public MainViewModel()
        {
            // Instantiate the collection object
            BoardList = DataProvider.GetBoards();

            if (BoardList.Count == 0)
            {
                // Create board
                BoardViewModel newBoard = new BoardViewModel
                {
                    BoardName = "New Board"
                };

                // Add to collection and db
                int newBoardId = DataProvider.AddBoard("New Board", "");
                newBoard.BoardId = newBoardId.ToString();
                newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
                BoardList.Add(newBoard);
                Current = newBoard;
            }
            else
            {
                allTasks = new ObservableCollection <CustomKanbanModel>();
                allTasks = DataProvider.GetData();
                foreach (var board in BoardList)
                {
                    foreach (var task in allTasks)
                    {
                        if (task.BoardId == board.BoardId)
                        {
                            board.Tasks.Add(task);
                        }
                    }
                }

                Current = BoardList[0];
            }
        }
        public void CreateBoard()
        {
            // Create board
            BoardViewModel newBoard = new BoardViewModel
            {
                BoardName  = BoardName,
                BoardNotes = BoardNotes
            };

            // Add board to db and collection
            int newBoardId = DataProvider.AddBoard(BoardName, BoardNotes);

            newBoard.BoardId = newBoardId.ToString();
            newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
            foreach (var task in allTasks)
            {
                if (task.BoardId == newBoardId.ToString())
                {
                    newBoard.Tasks.Add(task);
                }
            }
            BoardList.Add(newBoard);
        }
 /// <summary>
 /// Clears tasks collection and removes board from list.
 /// Then deletes the board and its tasks from the database
 /// </summary>
 /// <param name="currentBoard"></param>
 /// <returns>If deletion was successful</returns>
 internal bool DeleteBoard(BoardViewModel currentBoard)
 {
     currentBoard.Tasks.Clear();
     BoardList.Remove(currentBoard);
     return(DataProvider.DeleteBoard(currentBoard.BoardId));
 }