Ejemplo n.º 1
0
        public BoardModel AddMemberToBoard([FromBody] AddMemberBoardModel model, string token)
        {
            var session     = IsTokenExpired(token);
            var memberToAdd = _readOnlyRepository.GetById <Account>(model.MemberId);
            var board       = _readOnlyRepository.GetById <Board>(model.BoardId);

            if (board != null && memberToAdd != null)
            {
                board.AddMember(memberToAdd);
                memberToAdd.AddBoard(board);
                var    updateBoard  = _writeOnlyRepository.Update(board);
                var    boardModel   = _mappingEngine.Map <Board, BoardModel>(updateBoard);
                string activityDone = "Add " + memberToAdd.FirstName + " " + memberToAdd.LastName;
                board.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                return(boardModel);
            }
            throw  new BadRequestException("Member or Board does not exist");
        }
Ejemplo n.º 2
0
        public ReturnModel AddMember([FromBody] AddMemberBoardModel model, string accesToken)
        {
            var         account = _readOnlyRepository.First <Account>(account1 => account1.Token == accesToken);
            ReturnModel remodel = new ReturnModel();

            if (account.VerifyToken(account))
            {
                var memberToAdd = _readOnlyRepository.GetById <Account>(model.MemberId);
                var board       = _readOnlyRepository.GetById <Board>(model.BoardId);
                board.AddMember(memberToAdd);
                var      updateBoard = _writeOnlyRepository.Update(board);
                var      boardModel  = _mappingEngine.Map <Board, AccountBoardsModel>(updateBoard);
                Activity activity    = new Activity();
                activity.Text = account.FirstName + " Agrego a " + memberToAdd.FirstName + " al board: " + board.Title;
                account.AddActivities(activity);
                return(boardModel);
            }
            return(remodel.ConfigureModel("Error", "Su session ya expiro", remodel));
        }