Ejemplo n.º 1
0
        public IEnumerable <CardDTO> GetCardsByListId(string listId)
        {
            var result = db_.GetCardsByListId(listId)
                         .Select(c => new CardDTO(c.Id.ToString(),
                                                  c.Name,
                                                  c.Order,
                                                  c.Description,
                                                  listId,
                                                  c.Comments.Select(com => new CommentDTO(com.Id.ToString(), com.UserId.ToString(), com.Text)).ToList(),
                                                  c.Labels.Select(l => db_.GetLabelById(l)).ToList(), c.DueDate));

            return(result);
        }
Ejemplo n.º 2
0
        //public List<BoardDTO> GetBoardsByUserID(string userID)
        //{
        //    var boardsModel = db_.getBoardsByUser(userID).ToList();
        //    return boardsModel.Select(b => new BoardDTO(b.Id.ToString(), b.BoardName, b.Starred, b.Color, b.OrderNo)).ToList();
        //}

        public BoardDTO GetById(string id)
        {
            BoardModel            board = db_.GetBoardById(id);
            IEnumerable <ListDTO> lists = new List <ListDTO>();

            var tempLists = db_.GetListByBoardId(id);

            if (tempLists != null)
            {
                lists = tempLists.Select(l => new ListDTO(l.Id.ToString(), l.Name, l.Order, l.Description)).OrderBy(l => l.Order).ToList();
                foreach (var list in lists)
                {
                    var tempCards = db_.GetCardsByListId(list.Id);
                    if (tempCards != null)
                    {
                        list.Cards = tempCards.Select(c => new CardDTO(c.Id.ToString(),
                                                                       c.Name,
                                                                       c.Order,
                                                                       c.Description,
                                                                       list.Id.ToString(),
                                                                       c.Comments.Select(com => new CommentDTO(com.Id.ToString(), com.UserId.ToString(), com.Text)).ToList(),
                                                                       c.Labels.Select(l => db_.GetLabelById(l)).ToList(),
                                                                       c.DueDate))
                                     .OrderBy(c => c.Order);
                    }
                }
            }

            var result = new BoardDTO(board.Id.ToString(), board.BoardName, board.Starred, board.Color, board.UserCreatedBy.ToString(), lists);

            result.AllLabels = db_.GetLabels();

            return(result);
        }