public void LoadRouteVideoData() { // join valid video and (no specify valid) route switch (_climbMode) { case ClimbMode.Training: routeVideoViewModels = from video in TrainingRouteVideoDataAccess.ValidTrainingRouteVideosByRouteId(_routeId) join route in TrainingRouteDataAccess.TrainingRoutes on video.Route equals route.RouteID select new RouteVideoViewModel { VideoID = video.VideoID, VideoNo = video.VideoNo, RouteID = video.Route, RouteNo = route.RouteNo, IsDemo = video.IsDemo.GetValueOrDefault(false), CreateDT = video.CreateDT.GetValueOrDefault(), CreateDTString = FormatVideoCreateDTStringForDisplay( video.CreateDT.GetValueOrDefault()), RouteClimbMode = _climbMode }; break; case ClimbMode.Boulder: default: routeVideoViewModels = from video in BoulderRouteVideoDataAccess.ValidBoulderRouteVideosByRouteId(_routeId) join route in BoulderRouteDataAccess.BoulderRoutes on video.Route equals route.RouteID select new RouteVideoViewModel { VideoID = video.VideoID, VideoNo = video.VideoNo, RouteID = video.Route, RouteNo = route.RouteNo, IsDemo = video.IsDemo.GetValueOrDefault(false), CreateDT = video.CreateDT.GetValueOrDefault(), CreateDTString = FormatVideoCreateDTStringForDisplay( video.CreateDT.GetValueOrDefault()), RouteClimbMode = _climbMode }; break; } NonDemoRouteVideoViewModels = new ObservableCollection <RouteVideoViewModel>( routeVideoViewModels.Where(x => x.IsDemo == false)); }
// can be called by the view during Page.OnLoad public void LoadData() { List <string> years = DateTimeHelper.GetYearsForComboBox().ToList(); List <string> months = DateTimeHelper.GetMonthsForComboBox(MonthToStringFormat).ToList(); List <string> days = DateTimeHelper.GetDaysForComboBox(DayToStringFormat).ToList(); List <FilterHourViewModel> hours = DateTimeHelper.GetHoursForComboBox(HourToStringFormat).ToList(); // join valid video and (no specify valid) route IEnumerable <RouteVideoViewModel> videoViewModels; switch (_climbMode) { case ClimbMode.Training: videoViewModels = from video in TrainingRouteVideoDataAccess.ValidTrainingRouteVideosByRouteId(_routeId) join route in TrainingRouteDataAccess.TrainingRoutes on video.Route equals route.RouteID select new RouteVideoViewModel { VideoID = video.VideoID, VideoNo = video.VideoNo, RouteID = video.Route, RouteNo = route.RouteNo, IsDemo = video.IsDemo.GetValueOrDefault(false), CreateDT = video.CreateDT.GetValueOrDefault(), CreateDTString = FormatVideoCreateDTStringForDisplay( video.CreateDT.GetValueOrDefault()) }; break; case ClimbMode.Boulder: default: videoViewModels = from video in BoulderRouteVideoDataAccess.ValidBoulderRouteVideosByRouteId(_routeId) join route in BoulderRouteDataAccess.BoulderRoutes on video.Route equals route.RouteID select new RouteVideoViewModel { VideoID = video.VideoID, VideoNo = video.VideoNo, RouteID = video.Route, RouteNo = route.RouteNo, IsDemo = video.IsDemo.GetValueOrDefault(false), CreateDT = video.CreateDT.GetValueOrDefault(), CreateDTString = FormatVideoCreateDTStringForDisplay( video.CreateDT.GetValueOrDefault()) }; break; } // add null item at the front of the combo boxes if (_yearListFirstItem != null) { years.Insert(0, _yearListFirstItem); } if (_monthListFirstItem != null) { months.Insert(0, _monthListFirstItem); } if (_dayListFirstItem != null) { days.Insert(0, _dayListFirstItem); } if (_hourListFirstItem != null) { hours.Insert(0, _hourListFirstItem); } Years = new ObservableCollection <string>(years); Months = new ObservableCollection <string>(months); Days = new ObservableCollection <string>(days); Hours = new ObservableCollection <FilterHourViewModel>(hours); RouteVideoViewModels = new ObservableCollection <RouteVideoViewModel>(videoViewModels); }