public async Task <ActionResult> Index(int?year, int?month) { List <IQueryParameter> filters = new List <IQueryParameter>(); filters.AddRange(new IQueryParameter[] { new EqualsFilter("system.type", TYPE_NAME), new DepthParameter(0), new OrderParameter(ELEMENT_NAME) }); string yearString = null; string monthString = null; if (year.HasValue && !month.HasValue) { yearString = $"{year}-01"; monthString = $"{year + 1}-01"; } else if (year.HasValue && month.HasValue) { if (month < 12) { yearString = $"{year}-{GetMonthFormatted(month.Value)}"; monthString = $"{year}-{GetMonthFormatted(month.Value + 1)}"; } else { yearString = $"{year}-12"; monthString = $"{year + 1}-01"; } } if (year.HasValue) { filters.Add(new RangeFilter(ELEMENT_NAME, yearString, monthString)); } var pageBody = await _deliveryClient.GetItemsAsync <Article>(filters); var navigation = await _menuItemGenerator.GenerateItemsAsync(await _navigationProvider.GetNavigationAsync()); var pageViewModel = new PageViewModel { Navigation = navigation, Body = pageBody.Items }; return(View(DEFAULT_VIEW, pageViewModel)); }
private async Task <ViewResult> RenderViewAsync(IEnumerable <string> codenames, string viewName) { var navigation = await _menuItemGenerator.GenerateItemsAsync(await _navigationProvider.GetNavigationAsync()); // Separate request for page body content. Separate caching, separate depth of modular content. var pageBody = await _deliveryClient.GetItemsAsync <object>(new InFilter("system.codename", codenames.ToArray())); var pageViewModel = new PageViewModel { Navigation = navigation, Body = pageBody.Items }; return(View((string.IsNullOrEmpty(viewName) ? DEFAULT_VIEW : viewName), pageViewModel)); }