Ejemplo n.º 1
0
        public SuccessfulMessageResponse MoveCard([FromBody] CardMovedModel model, string token)
        {
            var session      = IsTokenExpired(token);
            var cardToMove   = _readOnlyRepository.GetById <Card>(model.CardToMove_id);
            var laneFromMove = _readOnlyRepository.GetById <Lane>(model.OldLane_id);
            var laneToMove   = _readOnlyRepository.GetById <Lane>(model.NewLane_id);
            var lane         = _readOnlyRepository.First <Lane>(lane1 => lane1.Cards.Contains(cardToMove));
            var board        = _readOnlyRepository.First <Board>(board1 => board1.Lanes.Contains(laneToMove));

            if (laneFromMove != null && laneToMove != null && cardToMove != null)
            {
                laneFromMove.Cards.ToList().Remove(cardToMove);
                laneToMove.AddCards(cardToMove);
                Lane laneFromMoveUpdated = _writeOnlyRepository.Update(laneFromMove);
                Lane laneToMoveUpdated   = _writeOnlyRepository.Update(laneToMove);
                cardToMove.Position = 5;
                laneToMove.AddCards(cardToMove);
                Card cardMoved = _writeOnlyRepository.Update(cardToMove);
                if (cardMoved != null && laneFromMoveUpdated != null && laneToMoveUpdated != null)
                {
                    string activityDone = "Moved " + cardMoved.Text + " from " + laneFromMove.Title + " to " + laneToMove.Title;
                    board.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                    return(new SuccessfulMessageResponse("Card was successfully moved"));
                }
            }
            throw new BadRequestException("Card could not be moved");
        }
Ejemplo n.º 2
0
        public static CardModel MoveCard(CardMovedModel cardMoved, string token)
        {
            var client  = new RestClient(BaseUrl);
            var request = InitRequest("/cards/move/" + token, Method.POST, cardMoved);
            IRestResponse <CardModel> response = client.Execute <CardModel>(request);

            return(response.Data);
        }