示例#1
0
        public int AddCard(Card card)
        {
            if (card == null)
            {
                throw new Exception("AddCard method error: Card is null");
            }


            var todolist = new Todolist
            {
                Title   = "Todolist",
                TodoIds = ""
            };

            _todolistContext.Todolists.Add(todolist);
            _todolistContext.SaveChanges();

            card.TodolistId = todolist.Id;
            _db.Cards.Add(card);
            _db.SaveChanges();

            var board = _dbBoard.Boards.Find(card.BoardId);

            board.AddCardId(card.Id);
            _dbBoard.Boards.Update(board);
            _dbBoard.SaveChanges();

            var column = _dbColumn.Columns.Find(card.ColumnId);

            column.AddCardId(card.Id);
            _dbColumn.Columns.Update(column);
            _dbColumn.SaveChanges();

            return(card.Id);
        }
示例#2
0
        public int AddColumn(Column column)
        {
            if (column == null)
            {
                throw new Exception("AddColumn method error: column is null");
            }
            var board = _dbBoards.Boards.Find(column.BoardId);

            if (board == null)
            {
                throw new Exception("AddColumn method error: board is null");
            }
            _db.Columns.Add(column);
            _db.SaveChanges();
            board.AddColumnId(column.Id);
            _dbBoards.Update(board);
            _dbBoards.SaveChanges();
            return(column.Id);
        }