private TimeEntryType GetMostUsedTimeEntryType(DayItemHeaderViewmodel dayItemHeaderViewmodel) { var timeEntries = dayItemHeaderViewmodel.TimeEntries .ToList(); if (!timeEntries.Any()) { return(TimeEntryTypes.SingleOrDefault(x => x.IsDefault)); // Can be empty if resync is in progress } var mostUsedTimeEntryType = timeEntries .GroupBy(x => x.TimeEntryType.Id) .OrderByDescending(x => x.Count()) .First().Key; return(TimeEntryTypes.SingleOrDefault(x => x.Id == mostUsedTimeEntryType)); // Can be empty if resync is in progress }
private void UpdateDay6() { Day6 = new DayItemHeaderViewmodel(StartDate.AddDays(5), Rows.Select(x => x.Saturday)); Day6.SelectTimeEntryType = GetMostUsedTimeEntryType(Day6); }
private void UpdateDay7() { Day7 = new DayItemHeaderViewmodel(StartDate.AddDays(6), Rows.Select(x => x.Sunday)); Day7.SelectTimeEntryType = GetMostUsedTimeEntryType(Day7); }
private void UpdateDay5() { Day5 = new DayItemHeaderViewmodel(StartDate.AddDays(4), Rows.Select(x => x.Friday)); Day5.SelectTimeEntryType = GetMostUsedTimeEntryType(Day5); }
private void UpdateDay4() { Day4 = new DayItemHeaderViewmodel(StartDate.AddDays(3), Rows.Select(x => x.Thursday)); Day4.SelectTimeEntryType = GetMostUsedTimeEntryType(Day4); }
private void UpdateDay3() { Day3 = new DayItemHeaderViewmodel(StartDate.AddDays(2), Rows.Select(x => x.Wednesday)); Day3.SelectTimeEntryType = GetMostUsedTimeEntryType(Day3); }
private void UpdateDay2() { Day2 = new DayItemHeaderViewmodel(StartDate.AddDays(1), Rows.Select(x => x.Tuesday)); Day2.SelectTimeEntryType = GetMostUsedTimeEntryType(Day2); }
private void UpdateDay1() { Day1 = new DayItemHeaderViewmodel(StartDate, Rows.Select(x => x.Monday)); Day1.SelectTimeEntryType = GetMostUsedTimeEntryType(Day1); }