public static BoardModel RenameBoard(RenameBoardModel boardRename, string token)
        {
            var client  = new RestClient(BaseUrl);
            var request = InitRequest("/boards/rename/" + token, Method.PUT, boardRename);
            IRestResponse <BoardModel> response = client.Execute <BoardModel>(request);

            return(response.Data);
        }
Example #2
0
        public SuccessfulMessageResponse RenameBoard([FromBody] RenameBoardModel model, string token)
        {
            var session       = IsTokenExpired(token);
            var account       = _readOnlyRepository.First <Account>(account1 => account1.Id == session.User.Id);
            var boardToRename = _readOnlyRepository.First <Board>(board1 => board1.Id == model.BoardToRename);

            if (boardToRename != null && boardToRename.Administrador == account)
            {
                boardToRename.Title = model.NewTitle;
                Board boardCreated = _writeOnlyRepository.Update(boardToRename);
                if (boardCreated != null)
                {
                    string activityDone = "Changed " + model.BoardToRename + " for " + model.NewTitle;
                    boardToRename.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                    return(new SuccessfulMessageResponse("The board has been renamed"));
                }
                throw new BadRequestException("You can't change the Title");
            }

            throw new BadRequestException("You aren't the administrator of the Board");
        }