public ActionResult Board(string id, string s = "", string e = "")
        {
            ChelloClient client = TrelloClientFactory.Get();
            Board board = client.Boards.Single(id);
            ViewBag.BoardName = board.Name;
            ViewBag.BoardId = id;

            DateTime startDate = DateTime.MinValue;
            DateTime endDate = DateTime.MaxValue;

            DateTime.TryParseExact(s, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out startDate);

            if (!DateTime.TryParseExact(e, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate))
            {
                endDate = DateTime.MaxValue;
            }

            ActivityRepository repository = new ActivityRepository(id);
            CumulativeFlowModel cards = new CumulativeFlowModel(repository, startDate, endDate);
            CumulativeFlowModel points = null;

            if (repository.Lists.SelectMany(l => l.Cards).Any(c => c.Points.HasValue))
            {
                points = new CumulativeFlowModel(repository, startDate, endDate, (cs) => { return cs.Where(c => c.Points.HasValue).Sum(c => c.Points.Value); }, "Points");
            }

            return View(new DiagramsModel(cards, points));
        }
 public static void AddCard(this IDictionary<string, ActivityRepository.ActivityList> lists, string listId, ActivityRepository.ActivityCard card)
 {
     if (lists.ContainsKey(listId))
     {
         lists[listId].AddCard(card);
     }
 }
 public CumulativeFlowModel(ActivityRepository repository, DateTime displayStartDate, DateTime displayEndDate, Func<IEnumerable<ActivityRepository.ActivityCard>, int> calculation, string title)
 {
     _repository = repository;
     _beginTime = repository.BoardOpened;
     _endTime = repository.BoardClosed.HasValue ? repository.BoardClosed.Value : DateTime.UtcNow;
     _calculation = calculation;
     _title = title;
     _limitedByTrello = repository.LimitedByApi;
     _displayBeginTime = displayStartDate < _beginTime ? _beginTime : displayStartDate;
     _displayEndTime = displayEndDate > _endTime ? _endTime : displayEndDate;
 }
 public CumulativeFlowModel(ActivityRepository repository, DateTime displayStartDate, DateTime displayEndDate)
     : this(repository, displayStartDate, displayEndDate, (cards) => { return cards.Count(); }, "Cards")
 {
 }
 public CumulativeFlowModel(ActivityRepository repository, Func<IEnumerable<ActivityRepository.ActivityCard>, int> calculation, string title)
     : this(repository, DateTime.MinValue, DateTime.MaxValue, calculation, title)
 {
 }
 public CumulativeFlowModel(ActivityRepository repository)
     : this(repository, DateTime.MinValue, DateTime.MaxValue)
 {
 }