public ChecklistViewModel InitializeWith(Card.Checklist list) { Id = list.Id; Name = list.Name; _cardId = list.IdCard; var items = list.CheckItems.Select(item => _itemFactory().InitializeWith(_cardId, Id, item)); Items.Clear(); Items.AddRange(items); UpdateCounts(); return(this); }
public void Handle(ChecklistCreated message) { if (message.CardId != _cardId) { return; } var checklist = new Card.Checklist { IdBoard = _boardId, IdCard = _cardId, Id = message.ChecklistId, Name = message.Name, CheckItems = new List <Card.CheckItem>() }; var list = _checklistFactory().InitializeWith(checklist); Checklists.Insert(0, list); PublishAggregations(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Creates a card. </summary> /// /// <param name="name"> The name. </param> /// <param name="desc"> The description. </param> /// <param name="closed"> True if closed. </param> /// <param name="dueDate"> The due date. </param> /// /// <returns> The new card. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// private ExpectedObject CreateCard(string name, string desc, bool closed, DateTime dueDate) { Card c = trello.Cards.Add(name, list); if (c != null) { c.Desc = desc; c.Closed = closed; //c.IdList = "4f2b8b4d4f2cb9d16d3684c1"; c.IdBoard = board.GetBoardId(); if (dueDate > DateTime.MinValue) { c.Due = dueDate; } c.Labels = new List <Label>(); c.IdShort = 1; c.Checklists = new List <Card.Checklist>(); c.Url = "https://trello.com/b/bz7S3fiv/trello-microservice"; c.ShortUrl = "https://trello.com/b/bz7S3fiv"; c.Pos = 32768; c.DateLastActivity = SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime(); c.Badges = new Card.CardBadges { Votes = 1, Attachments = 1, Comments = 2, CheckItems = 0, CheckItemsChecked = 0, Description = true, Due = SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime().AddDays(1), FogBugz = "" }; c.IdMembers = new List <string> { "4f2b8b464f2cb9d16d368326" }; } if (dueDate == DateTime.MinValue) { Label l = new Label { Color = Color.Green, IdBoard = board.GetBoardId(), Name = "Green Label" }; c.Labels.Add(l); //// Label card trello.Cards.AddLabel(c, Color.Green); } trello.Cards.Update(c); // Assign member to card trello.Cards.AddMember(c, trello.Members.Me()); // Comment on a card trello.Cards.AddComment(c, RandomString(50)); Card.CheckItem ci = new Card.CheckItem(); ci.Pos = 994; ci.Name = "Draft"; ci.Id = RandomString(12); Card.Checklist cl = new Card.Checklist(); cl.IdBoard = board.GetBoardId(); cl.Name = "To Do"; cl.Pos = 2485; cl.CheckItems = new List <Card.CheckItem>(); c.Checklists.Add(cl); trello.Cards.Update(c); cl.CheckItems.Add(ci); trello.Cards.Update(c); card = c; return(c.ToExpectedObject()); }