Ejemplo n.º 1
0
        public IActionResult CreateFirstBoard([FromBody] FirstBoardDto boardDto)
        {
            var userId     = User.GetUserId();
            var addedBoard = _boardService.CreateFirstBoard(boardDto, userId);

            addedBoard.IsOwner = true;
            return(CreatedAtRoute("GetBoard", new { id = addedBoard.BoardId }, addedBoard));
        }
Ejemplo n.º 2
0
        public UserBoardDto CreateFirstBoard(FirstBoardDto boardDto, string userId)
        {
            var userBoard      = InitializeUserBoard(boardDto, userId);
            var addedUserBoard = _userBoardRepository.CreateUserBoard(userBoard);
            var result         = _mapper.Map <UserBoardDto>(addedUserBoard);

            result.Board.ObfuscatedId = _obfuscator.Obfuscate(result.BoardId);
            return(result);
        }
Ejemplo n.º 3
0
        private bool TryInitializeFirstCard(FirstBoardDto boardDto, out Card card)
        {
            card = null;

            if (string.IsNullOrEmpty(boardDto.CardName))
            {
                return(false);
            }
            card = new Card
            {
                Name = boardDto.CardName
            };
            return(true);
        }
Ejemplo n.º 4
0
        private UserBoard InitializeUserBoard(FirstBoardDto boardDto, string userId)
        {
            var hash      = Guid.NewGuid().ToString("N");
            var userBoard = new UserBoard
            {
                UserId = userId,
                Board  = new Board
                {
                    Name    = boardDto.BoardName,
                    OwnerId = userId,
                    Lists   = new List <List>(),
                    Hash    = hash
                }
            };
            var result = TryInitializeFirstList(boardDto, out List list);

            if (result)
            {
                userBoard.Board.Lists.Add(list);
            }
            return(userBoard);
        }
Ejemplo n.º 5
0
        private bool TryInitializeFirstList(FirstBoardDto boardDto, out List list)
        {
            list = null;

            if (string.IsNullOrEmpty(boardDto.ListName))
            {
                return(false);
            }

            list = new List
            {
                Name  = boardDto.ListName,
                Cards = new List <Card>()
            };

            var result = TryInitializeFirstCard(boardDto, out Card card);

            if (result)
            {
                list.Cards.Add(card);
            }

            return(true);
        }