public DailyAttendanceListViewModel(int selectedYear, int selectedMonth, DailyAttendanceCollection dailyAttendances) { SelectedYear = selectedYear.ToString(); SelectedMonth = selectedMonth.ToString(); YearSelectListItems = BuildYearSelectListItems(selectedYear); MonthSelectListItems = BuildMonthSelectListItems(selectedMonth); DailyAttendances = new OneMonthDailyAttendancesViewModel(new Month(selectedYear, selectedMonth), dailyAttendances);; }
public OneMonthDailyAttendancesViewModel(Month month, DailyAttendanceCollection dailyAttendances) { innerEnumerable = month.Dates.Select(date => { var exists = dailyAttendances.list.Any(d => d.Date == date); if (exists) { var dailyAttendance = dailyAttendances.list.First(d => d.Date == date); return(DailyAttendanceViewModel.FromEntity(dailyAttendance)); } else { return(DailyAttendanceViewModel.Empty(date)); } }); }