// This method is based on method of same name from Kanban.ApplicationServices.BoardService private LeanKit.API.Client.Library.TransferObjects.Lane FindFirstChildLane(LeanKit.API.Client.Library.TransferObjects.Lane parentLane, IList <LeanKit.API.Client.Library.TransferObjects.Lane> allLanes) { if (parentLane == null) { return(null); } return((parentLane.ChildLaneIds != null && parentLane.ChildLaneIds.Any()) ? FindFirstChildLane(allLanes.Where(x => x.ParentLaneId == parentLane.Id).OrderBy(x => x.Index).FirstOrDefault(), allLanes) : parentLane); }
public void ApplyCardMove(long cardId, long toLaneId, int position) { //get the card CardView currentCard = GetCardViewById(cardId); //remove from the lane it was in Lane lane = GetLaneById(currentCard.LaneId); int index = lane.Cards.IndexOf(currentCard); foreach (CardView cardView in lane.Cards.OrderBy(card => card.Index)) { if (cardView.Index > currentCard.Index) { cardView.Index--; } } lane.Cards.RemoveAt(index); //move the card into the new lane bool inserted = false; int indexToInsert = 0; Lane destinationLane = GetLaneById(toLaneId); if (destinationLane.Cards == null) { destinationLane.Cards = new List <CardView>(); } foreach (CardView cardView in destinationLane.Cards.OrderBy(card => card.Index)) { if (cardView.Index >= position) { if (!inserted) { indexToInsert = destinationLane.Cards.IndexOf(cardView); inserted = true; } else { cardView.Index++; } } } currentCard.Index = position; destinationLane.Cards.Insert(indexToInsert, currentCard); if (destinationLane.Id != null) { currentCard.LaneId = (long)destinationLane.Id; } }
public string GetLaneTitle(long laneId) { long parentLaneId = 0; Lane parentLane = Lanes.FirstOrDefault(x => x.ChildLaneIds != null && x.ChildLaneIds.Contains(laneId)); if (parentLane != null) { parentLaneId = parentLane.Id.GetValueOrDefault(0); } if (parentLaneId != 0) { return(GetLaneTitle(parentLaneId) + ":" + GetLaneById(laneId).Title); } return(GetLaneById(laneId).Title); }
public Lane GetLaneById(long laneId) { Lane lane = Lanes.FirstOrDefault(x => x.Id == laneId); if (lane == null) { lane = Backlog.FirstOrDefault(x => x.Id == laneId); } if (lane == null) { lane = Archive.FirstOrDefault(x => x.Id == laneId); } return(lane); }
public void UpdateLane(Lane laneToUpdateWith) { //Try getting the lane from the Lanes Lane regularLaneToReplace = Lanes.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (regularLaneToReplace != null) { int laneIndex = Lanes.IndexOf(regularLaneToReplace); Lanes.RemoveAt(laneIndex); Lanes.Insert(laneIndex, laneToUpdateWith); return; } //If none, try getting from Backlog Lane backLogLaneToReplace = Backlog.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (backLogLaneToReplace != null) { int laneIndex = Backlog.IndexOf(backLogLaneToReplace); Backlog.RemoveAt(laneIndex); Backlog.Insert(laneIndex, laneToUpdateWith); return; } //Lastly, get it from Archive Lane archiveLaneToReplace = Archive.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (archiveLaneToReplace != null) { int laneIndex = Archive.IndexOf(archiveLaneToReplace); Archive.RemoveAt(laneIndex); Archive.Insert(laneIndex, laneToUpdateWith); return; } throw new ItemNotFoundException("Could not find the Lane to replace with the updated Lane."); }
public void CallWillAddCard() { Board board = GetSampleBoard(); _apiMock.Expect(x => x.GetBoard(1)).Return(board); Card cardToAdd = new Card { Id = 1, Title = "Card 1 Updated", LaneId = 1, Description = "some desc 1", TypeId = 1, ExternalCardID = "123" }; Lane affectedLane = new Lane { Id = 1, Title = "Lane 1", Cards = new List<CardView> { new CardView { Id = 1, Title = "Card 1", LaneId = 1, Description = "some desc 1", Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"} }, new CardView { Id = 2, Title = "Card 2", LaneId = 1, Description = "some desc 2", Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"} }, new CardView { Id = 4, Title = "Card 4", LaneId = 1, Description = "some desc 4", Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"} }, }, }; CardAddResult result = new CardAddResult {BoardVersion = 1, CardId = 4, Lane = affectedLane}; _apiMock.Expect(x => x.AddCard(Arg<long>.Is.Anything, Arg<Card>.Is.Anything)).Return(result); _integration = new LeanKitIntegration(1, _apiMock); _integration.ShouldContinue = false; _integration.StartWatching(); _integration.AddCard(cardToAdd); Card card = _integration.GetCard(4); Assert.NotNull(card); Assert.AreEqual("Card 4", card.Title); }
private void MapChildLanes(IList <LeanKit.API.Client.Library.TransferObjects.Lane> lanes, LeanKit.API.Client.Library.TransferObjects.Lane parentLane, LaneModel parentLaneModel, int level) { parentLaneModel.ChildLanes = new List <LaneModel>(); parentLaneModel.IsParent = false; parentLaneModel.Level = level; if (parentLane.ChildLaneIds.Count == 0) { return; } parentLaneModel.IsParent = true; level++; foreach (var childLaneId in parentLane.ChildLaneIds) { var childLane = lanes.FirstOrDefault(x => x.Id == childLaneId); var childLaneModel = Mapper.Map <LaneModel>(childLane); MapChildLanes(lanes, childLane, childLaneModel, level); childLaneModel.Level = level; parentLaneModel.ChildLanes.Add(childLaneModel); } }
public WipOverrideEvent(DateTime eventDateTime, string comment, Lane lane) : base(eventDateTime) { WipOverrideComment = comment; LaneToOverrideWip = lane; }
public CardMoveEvent(DateTime eventDateTime, Lane fromLane, Lane toLane, Card movedCard) : base(eventDateTime) { FromLane = fromLane; ToLane = toLane; MovedCard = movedCard; }