public async Task <IActionResult> Detail(int id) { var board = await _boardService.GetBoardInfo(id); var model = new BoardView(); model.Id = board.Id; model.Title = board.Title; foreach (var column in board.Columns) { var modelColumn = new BoardView.Column { Title = column.Title, Id = column.Id }; foreach (var card in column.Cards) { var modelCard = new BoardView.Card { Id = card.Id, Title = card.Title }; modelColumn.Cards.Add(modelCard); } model.Columns.Add(modelColumn); } return(View(model)); }
public BoardView GetBoard(int id) { var model = new BoardView(); var board = context.Boards .Include(b => b.Columns) .ThenInclude(c => c.Cards) .FirstOrDefault(x => x.Id == id); model.Id = board.Id; model.BoardTitle = board.Title; foreach (var column in board.Columns) { var modelColumn = new BoardView.Column { Title = column.Title }; foreach (var card in column.Cards) { var modelCard = new BoardView.Card { Id = card.Id, Content = card.Contents }; modelColumn.Cards.Add(modelCard); } model.Columns.Add(modelColumn); } return(model); }
public BoardView GetBoardView(int id) { var modelBoard = new BoardView(); var dbBoard = _dbContext.Boards .Include(b => b.Columns) .ThenInclude(c => c.Cards) .SingleOrDefault(x => x.Id == id); modelBoard.Title = dbBoard.Title; modelBoard.Id = dbBoard.Id; foreach (var dbColumn in dbBoard.Columns) { var modelColumn = new BoardView.Column() { Id = dbColumn.Id, Title = dbColumn.Title }; foreach (var dbCard in dbColumn.Cards) { var modelCard = new BoardView.Card() { Id = dbCard.Id, Content = dbCard.Contents }; modelColumn.Cards.Add(modelCard); } modelBoard.Columns.Add(modelColumn); } return(modelBoard); }
public BoardView GetBoard(int id) { var model = new BoardView(); var board = dbContext.Boards .Include(b => b.Columns) // Init Lazy Loading of related Table .ThenInclude(c => c.Cards) .SingleOrDefault(x => x.Id == id); model.Id = board.Id; model.Title = board.Title; foreach (var item in board.Columns) { var modelColumn = new BoardView.Column(); modelColumn.Title = item.Title; modelColumn.Id = item.Id; foreach (var card in item.Cards) { var modelCard = new BoardView.Card(); modelCard.Content = card.Contents; modelCard.Id = card.Id; modelColumn.Cards.Add(modelCard); } model.Columns.Add(modelColumn); } return(model); }
public BoardView GetBoard(int id) { var model = new BoardView(); var board = _dbContext.Boards .Include(b => b.Columns) .ThenInclude(c => c.Cards) .SingleOrDefault(x => x.BoardID == id); if (board == null) { return(model); } model.Id = board.BoardID; foreach (var column in board.Columns) { var modelColumn = new BoardView.Column { Title = column.ColumnName, Id = column.ColumnID }; foreach (var card in column.Cards) { var modelCard = new BoardView.Card { Id = card.CardID, Content = card.CardName }; modelColumn.Cards.Add(modelCard); } model.Columns.Add(modelColumn); } return(model); }