Example #1
0
        public HomeViewModel()
        {
            var damSnapshotRepository = new DamSnapshotRepository(() => new DataContext());
            var latestSnapshots       = damSnapshotRepository.Items.GroupBy(x => x.Dam)
                                        .Select(x => x.MaxBy(snapshot => snapshot.Date))
                                        .OrderByDescending(snapshot => snapshot.Dam.Capacity)
                                        .ToList();

            DamRows = latestSnapshots.Select(x => new DamRowViewModel(x,
                                                                      damSnapshotRepository.Items
                                                                      .SingleOrDefault(y => x.Dam == y.Dam && x.Date.AddYears(-1) == y.Date)))
                      .ToList();
            LastUpdate = latestSnapshots.Max(snapshot => snapshot.Date);
        }
 public void SetUp()
 {
     DataAccessTestHelper.Initialize();
     _damRepository         = new DamRepository(() => new DataContext());
     _damSnapshotRepository = new DamSnapshotRepository(() => new DataContext());
 }