private List <MonthViewViewModel> GetMonthsViewModel(DateTime dateTime, bool wholeYear = false) { string languageFilter = httpContextAccessor.HttpContext.Request.Headers["Accept-Language"]; ViewBag.PreviousMonth = dateTime.AddMonths(-1).Date; ViewBag.NextMonth = dateTime.AddMonths(1).Date; ViewBag.CurrentMonth = dateTime.Date; //unique list of years for the top of archives var daysWithEntries = archiveManager.GetDaysWithEntries(); ViewBag.Years = daysWithEntries.Select(i => i.Year).Distinct(); EntryCollection entries; if (wholeYear) { entries = archiveManager.GetEntriesForYear(dateTime, languageFilter); } else { entries = archiveManager.GetEntriesForMonth(dateTime, languageFilter); } //TODO: Do I need this? //entries = new EntryCollection(entries.OrderBy(e => e.CreatedUtc)); DefaultPage(ARCHIVE); return(MonthViewViewModel.Create(dateTime, entries, mapper)); }
private List <MonthViewViewModel> GetMonthsViewModel(DateTime dateTime, bool wholeYear = false) { string languageFilter = httpContextAccessor.HttpContext.Request.Headers["Accept-Language"]; ViewBag.PreviousMonth = dateTime.AddMonths(-1).Date; ViewBag.NextMonth = dateTime.AddMonths(1).Date; ViewBag.CurrentMonth = dateTime.Date; var stopWatch = new Stopwatch(); stopWatch.Start(); //unique list of years for the top of archives var daysWithEntries = archiveManager.GetDaysWithEntries(); ViewBag.Years = daysWithEntries.Select(i => i.Year).Distinct(); EntryCollection entries; if (wholeYear) { entries = archiveManager.GetEntriesForYear(dateTime, languageFilter); } else { entries = archiveManager.GetEntriesForMonth(dateTime, languageFilter); } stopWatch.Stop(); logger.LogInformation(new DasBlog.Services.ActivityLogs.EventDataItem(EventCodes.Site, null, $"ArchiveController (Date: {dateTime.ToLongDateString()}; Year: {wholeYear}) Time elapsed: {stopWatch.Elapsed.TotalMilliseconds}ms")); DefaultPage(ARCHIVE); return(MonthViewViewModel.Create(dateTime, entries, mapper)); }
private MonthViewViewModel GetMonthsViewModel(DateTime dateTime) { string languageFilter = httpContextAccessor.HttpContext.Request.Headers["Accept-Language"]; ViewBag.PreviousMonth = dateTime.AddMonths(-1).Date; ViewBag.NextMonth = dateTime.AddMonths(1).Date; ViewBag.CurrentMonth = dateTime.Date; var entries = archiveManager.GetEntriesForMonth(dateTime, languageFilter); return(MonthViewViewModel.Create(dateTime, entries, mapper)); }